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

2024-11-19 00:06:05 +0800 CST views 3116
正常我们的上传标签都是这样写的<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

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

推荐文章

Go语言中实现RSA加密与解密
2024-11-18 01:49:30 +0800 CST
阿里云发送短信php
2025-06-16 20:36:07 +0800 CST
pycm:一个强大的混淆矩阵库
2024-11-18 16:17:54 +0800 CST
底部导航栏
2024-11-19 01:12:32 +0800 CST
Linux 网站访问日志分析脚本
2024-11-18 19:58:45 +0800 CST
Golang在整洁架构中优雅使用事务
2024-11-18 19:26:04 +0800 CST
mysql int bigint 自增索引范围
2024-11-18 07:29:12 +0800 CST
Vue3中如何进行异步组件的加载?
2024-11-17 04:29:53 +0800 CST
Go 单元测试
2024-11-18 19:21:56 +0800 CST
ElasticSearch简介与安装指南
2024-11-19 02:17:38 +0800 CST
如何在Rust中使用UUID?
2024-11-19 06:10:59 +0800 CST
Rust 中的所有权机制
2024-11-18 20:54:50 +0800 CST
Vue3中的Store模式有哪些改进?
2024-11-18 11:47:53 +0800 CST
Claude:审美炸裂的网页生成工具
2024-11-19 09:38:41 +0800 CST
JavaScript设计模式:发布订阅模式
2024-11-18 01:52:39 +0800 CST
程序员茄子在线接单