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

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

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

推荐文章

对多个数组或多维数组进行排序
2024-11-17 05:10:28 +0800 CST
html夫妻约定
2024-11-19 01:24:21 +0800 CST
Vue3中的响应式原理是什么?
2024-11-19 09:43:12 +0800 CST
go命令行
2024-11-18 18:17:47 +0800 CST
推荐几个前端常用的工具网站
2024-11-19 07:58:08 +0800 CST
前端如何给页面添加水印
2024-11-19 07:12:56 +0800 CST
JS 箭头函数
2024-11-17 19:09:58 +0800 CST
js函数常见的写法以及调用方法
2024-11-19 08:55:17 +0800 CST
JavaScript设计模式:发布订阅模式
2024-11-18 01:52:39 +0800 CST
windon安装beego框架记录
2024-11-19 09:55:33 +0800 CST
支付宝批量转账
2024-11-18 20:26:17 +0800 CST
7种Go语言生成唯一ID的实用方法
2024-11-19 05:22:50 +0800 CST
Nginx 防盗链配置
2024-11-19 07:52:58 +0800 CST
Shell 里给变量赋值为多行文本
2024-11-18 20:25:45 +0800 CST
禁止调试前端页面代码
2024-11-19 02:17:33 +0800 CST
linux设置开机自启动
2024-11-17 05:09:12 +0800 CST
Rust 与 sqlx:数据库迁移实战指南
2024-11-19 02:38:49 +0800 CST
如何在 Linux 系统上安装字体
2025-02-27 09:23:03 +0800 CST
Golang 随机公平库 satmihir/fair
2024-11-19 03:28:37 +0800 CST
程序员茄子在线接单