编程 巧用opacity实现input的文件上传美化

2024-11-19 00:06:05 +0800 CST views 2872
正常我们的上传标签都是这样写的<input  type="file" accept="image/*" />
这样显示出来的原生按钮不仅不利于用户体验。我们自己都觉得丑。所有我们需要进行美化下。

html代码

<div class="box" id="s1">
	<input data-id="s1" type="file" accept="image/*" class="upload-file" data-type="0">
	<div class="images">
		<i class="iconfont icon-shenfenzhengzhengmian"></i>
	</div>
	<div class="about">
		身份证头像面
	</div>
</div>
<div class="box" id="s2">
	<input data-id="s2" type="file" accept="image/*" class="upload-file" data-type="1">
	<div class="images">
		<i class="iconfont icon-shenfenzhengfanmian"></i>
	</div>
	<div class="about">
		身份证国徽面
	</div>
</div>

css代码

.iconfont{
        font-size: 100px;
    }
    .images img{
        width:auto;
        height:100px;
        overflow: hidden; 
    }
    .box{
        position: relative;
    }
    .upload-file{
        position: absolute;
        width:100%;
        background-color: sienna;
        height: 100%;
        left: 0;
        top: 0;
        opacity: .01; 
        filter: Alpha(opacity=1);
        
    }

实际案例

2.png

1.png

复制全文 生成海报 前端开发 用户界面 网页设计

推荐文章

Python 微软邮箱 OAuth2 认证 Demo
2024-11-20 15:42:09 +0800 CST
微信内弹出提示外部浏览器打开
2024-11-18 19:26:44 +0800 CST
在 Docker 中部署 Vue 开发环境
2024-11-18 15:04:41 +0800 CST
Elasticsearch 文档操作
2024-11-18 12:36:01 +0800 CST
PHP中获取某个月份的天数
2024-11-18 11:28:47 +0800 CST
快速提升Vue3开发者的效率和界面
2025-05-11 23:37:03 +0800 CST
详解 Nginx 的 `sub_filter` 指令
2024-11-19 02:09:49 +0800 CST
Go 语言实现 API 限流的最佳实践
2024-11-19 01:51:21 +0800 CST
2025,重新认识 HTML!
2025-02-07 14:40:00 +0800 CST
10个几乎无人使用的罕见HTML标签
2024-11-18 21:44:46 +0800 CST
JavaScript 异步编程入门
2024-11-19 07:07:43 +0800 CST
程序员茄子在线接单