css input[type=file]样式美化
input[type=file]是上传文件离不开的标签元素,但是默认样式太丑,完全不符合前端人对审美的需求,今天就来教大家如何改造默认样式。
首先给input[type=file]标签包装一个外围容器,这里我使用span元素,当然其他元素也可以。
代码如下:
<span id="uploadBtn">选择文件
<input type="file" class="file">
</span>
接下来的事情交给css来搞定
代码如下:
#uploadBtn{
display:inline-block;
position: relative;
color: #fff;
background-color: #1989fa;
border-color: #1989fa;
padding: 0 30px;
font-size: 14px;
line-height: 42px;
font-weight: 500;
-webkit-transition: all .15s;
transition: all .15s;
padding: 0 15px;
line-height: 32px;
border-radius: 4px;
}
.file{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
opacity: 0;
}
接下来就是效果展示了:
相关推荐
-
第18问:MySQL CPU 高了,怎么办?2025-02-24 10:27:18
-
mysql索引类型 normal, unique, full text
mysql索引类型 normal, unique, full text2025-02-24 10:05:05 -
uwsgi+django+nginx 搭建部分总结2025-02-24 10:03:33
-
使用Docker配置Nginx环境部署Nextcloud2025-02-24 10:02:03
-
Nginx安装和怎么使用2025-02-24 10:00:45