CSS ::file-selector-button伪元素修改input上传文件按钮的样式

默认样式
修改后的样式
html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>type:file</title>
    <style>
        .inputFile{
            /* 隐藏按钮后的文字 */
            font-size: 0;
        }
        /* 修改按钮后的文字颜色 */
        .inputFile[type="file"] {
            color: gray;
        }
        .inputFile::file-selector-button {
            height: 3rem;
            font-size: 1rem;
            color: #fff;
            border-radius: .25rem;
            border: 1px solid #f14a24;
            padding: .75rem 1rem;
            background-color: #f14a24;
            box-sizing: border-box;
            font-family: inherit;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <input type="file" class="inputFile">
</body>
</html>
相关推荐
二哈喇子!1 小时前
BOM模型
开发语言·前端·javascript·bom
二哈喇子!1 小时前
Vue2 监听器 watcher
前端·javascript·vue.js
yanyu-yaya1 小时前
前端面试题
前端·面试·前端框架
二哈喇子!2 小时前
使用NVM下载Node.js管理多版本
前端·npm·node.js
GGGG寄了2 小时前
HTML——文本标签
开发语言·前端·html
2501_944521593 小时前
Flutter for OpenHarmony 微动漫App实战:推荐动漫实现
android·开发语言·前端·javascript·flutter·ecmascript
Amumu121384 小时前
Vue核心(三)
前端·javascript·vue.js
CoCo的编程之路4 小时前
2026 前端效能革命:如何利用智能助手实现“光速”页面构建?深度横评
前端·人工智能·ai编程·comate·智能编程助手·文心快码baiducomate
RFCEO4 小时前
HTML编程 课程五、:HTML5 新增语义化标签
前端·html·html5·跨平台·语义化标签·可生成安卓/ios·html最新版本
2501_944521594 小时前
Flutter for OpenHarmony 微动漫App实战:图片加载实现
android·开发语言·前端·javascript·flutter·php