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;
}
接下来就是效果展示了:
相关推荐
-
Linux中完全删除nginx并重新安装2025-04-26 01:23:45
-
《前端运维》、Nginx-3静态资源服务、跨域与其他2025-04-26 00:51:36
-
nginx配置SSL总结2025-04-26 00:49:40
-
windows下安装nginx,并注册为系统服务,开机自启动
windows下安装nginx,并注册为系统服务,开机自启动2025-04-26 00:21:28 -
详解nginx利用referer指令实现防盗链配置2025-04-26 00:10:48