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

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

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

推荐文章

thinkphp swoole websocket 结合的demo
2024-11-18 10:18:17 +0800 CST
使用Rust进行跨平台GUI开发
2024-11-18 20:51:20 +0800 CST
Golang - 使用 GoFakeIt 生成 Mock 数据
2024-11-18 15:51:22 +0800 CST
用 Rust 构建一个 WebSocket 服务器
2024-11-19 10:08:22 +0800 CST
Nginx 性能优化有这篇就够了!
2024-11-19 01:57:41 +0800 CST
html5在客户端存储数据
2024-11-17 05:02:17 +0800 CST
在Vue3中实现代码分割和懒加载
2024-11-17 06:18:00 +0800 CST
使用Vue 3实现无刷新数据加载
2024-11-18 17:48:20 +0800 CST
如何在 Vue 3 中使用 Vuex 4?
2024-11-17 04:57:52 +0800 CST
百度开源压测工具 dperf
2024-11-18 16:50:58 +0800 CST
25个实用的JavaScript单行代码片段
2024-11-18 04:59:49 +0800 CST
PHP解决XSS攻击
2024-11-19 02:17:37 +0800 CST
一个收银台的HTML
2025-01-17 16:15:32 +0800 CST
10个极其有用的前端库
2024-11-19 09:41:20 +0800 CST
Vue3中的Slots有哪些变化?
2024-11-18 16:34:49 +0800 CST
Rust 并发执行异步操作
2024-11-19 08:16:42 +0800 CST
Vue 3 中的 Watch 实现及最佳实践
2024-11-18 22:18:40 +0800 CST
Go语言中的mysql数据库操作指南
2024-11-19 03:00:22 +0800 CST
利用Python构建语音助手
2024-11-19 04:24:50 +0800 CST
Python上下文管理器:with语句
2024-11-19 06:25:31 +0800 CST
Go语言SQL操作实战
2024-11-18 19:30:51 +0800 CST
windon安装beego框架记录
2024-11-19 09:55:33 +0800 CST
Golang 几种使用 Channel 的错误姿势
2024-11-19 01:42:18 +0800 CST
程序员茄子在线接单