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

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

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

推荐文章

Web 端 Office 文件预览工具库
2024-11-18 22:19:16 +0800 CST
Vue3的虚拟DOM是如何提高性能的?
2024-11-18 22:12:20 +0800 CST
Dropzone.js实现文件拖放上传功能
2024-11-18 18:28:02 +0800 CST
如何实现生产环境代码加密
2024-11-18 14:19:35 +0800 CST
介绍 Vue 3 中的新的 `emits` 选项
2024-11-17 04:45:50 +0800 CST
markdowns滚动事件
2024-11-19 10:07:32 +0800 CST
Nginx 负载均衡
2024-11-19 10:03:14 +0800 CST
H5抖音商城小黄车购物系统
2024-11-19 08:04:29 +0800 CST
JavaScript中设置器和获取器
2024-11-17 19:54:27 +0800 CST
解决 PHP 中的 HTTP 请求超时问题
2024-11-19 09:10:35 +0800 CST
css模拟了MacBook的外观
2024-11-18 14:07:40 +0800 CST
网络数据抓取神器 Pipet
2024-11-19 05:43:20 +0800 CST
Python设计模式之工厂模式详解
2024-11-19 09:36:23 +0800 CST
如何在Vue3中定义一个组件?
2024-11-17 04:15:09 +0800 CST
JavaScript 上传文件的几种方式
2024-11-18 21:11:59 +0800 CST
程序员茄子在线接单