改造input

效果图
在这里插入图片描述

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>改造input</title><style></style></head><body><input type="checkbox" name="" id="" /><input type="file" /><hr /><!-- 方法1: 点击label相当于点击了input--><style>.checkbox1 {display: none;}.checkbox1 + i {/* content: " "; */display: inline-block;font-style: normal;width: 20px;height: 20px;border-radius: 50%;background-color: #c0c0c0;}.checkbox1:checked + i {background-color: hotpink;}.checkbox1 + i::after {}.checkbox1:checked + i::after {content: " ";display: inline-block;margin: 5px;width: 10px;height: 10px;border-radius: 50%;background-color: #c0c0c0;}</style><label><input type="checkbox" class="checkbox1" /><i></i></label><!-- 方法2: 设置input的opacity为0, 定位方式为绝对定位 --><style>.btn {position: relative;display: inline-block;text-align: center;color: #fff;text-decoration: none;width: 80px;height: 32px;line-height: 32px;background: #409eff;border-radius: 3px;font-size: 12px;vertical-align: middle;margin-left: 10px;}input[name="file"] {opacity: 0;width: 100%;height: 100%;position: absolute;left: 0;}</style><a href="javascript:void(0)" class="btn">上传文件<input type="file" id="file" name="file" @change="uploadFile" /></a></body>
</html>

vue中改造input[type=‘file’]标签
在这里插入图片描述

<template>
<div>
<!-- 上传图片 --><div class="upload-file"><divclass="show-img"v-if="true"v-for="(item, index) in srcs":key="index"><img :src="item" alt="" /><span class="after" @click="removeFile(index)"><imgsrc="@/assets/images/Lib_slices/ico_feedback_delete@2x.png"alt=""/></span></div><!-- 文件上传按钮 --><a href="javascript:void(0)" class="btn" v-if="isShow"><span class="add-btn"><imgsrc="@/assets/images/Lib_slices/ico_feedback_add@2x.png"alt=""/></span><inputtype="file"accept="image/*"capture="camera"id="file"name="file"@change="uploadFile"/></a></div>
</div>
</template>
export default {data() {return {isShow: true,srcs: ["http://static.xingfeng.cool/images/avatar.jpeg","http://static.xingfeng.cool/images/zrf.jpeg",],}},methods: {uploadFile(file) {this.isShow = false;this.$indicator.open({text: "图片上传中...",spinnerType: "fading-circle",});},removeFile(index) {this.srcs.splice(index, 1);},}
}
.upload-file {margin-top: 0.98rem;background: #fff;position: relative;box-sizing: border-box;display: grid;grid-template-columns: 4.43rem 4.43rem 4.43rem 4.43rem;align-items: start;justify-items: start;grid-auto-flow: row;.show-img {width: 3.84rem;height: 3.84rem;position: relative;img {width: 100%;height: 100%;}.after {position: absolute;right: -0.26rem;top: -0.26rem;font-size: 1.04rem;width: 1.04rem;height: 1.04rem;line-height: 1.04rem;text-align: center;}}.btn {border: 1px dashed #666;position: relative;left: 0;display: inline-block;text-align: center;color: #fff;text-decoration: none;//   width: 100%;//   height: 100%;width: 3.84rem;height: 3.84rem;line-height: 2.08rem;font-size: 0.78rem;vertical-align: middle;box-sizing: border-box;.add-btn {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);display: flex;flex-direction: column;justify-content: space-between;align-items: center;width: 0.85rem;height: 0.85rem;img {width: 100%;height: 100%;}}#file {opacity: 0;width: 100%;height: 100%;position: absolute;left: 0;}}}

在这里插入图片描述

<style>
.file-upload {display: inline-block;width: 72px;height: 36px;line-height: 36px;text-align: center;color: #fff;position: relative;overflow: hidden;background: #3aa1f5;}.file-upload input {position: absolute;left: 0;top: 0;z-index: 10;opacity: 0;filter: Alpha(opacity=0);filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);color: transparent;width: 100%;height: 100%;cursor: pointer;font-size: 100px;background: transparent;}.file-upload span {font-size: 12px;font-weight: bold;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);width: 100%;height: 100%;}</style><label class="file-upload"><input type="file" name="file" /><span>上传附件</span></label>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/406635.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

配置Windows Server2008故障转移集群

Abner Kou原创配置Windows Server2008故障转移集群一、 问题描述建立双节点的Windows Server 2008 故障转移集群&#xff0c;为Hyper-v的高可用和SQLServer集群做好准备。二、 配置集群群前的准备1、 每个节点主机配备至少两块网卡&#xff0c;一块用于连接共享存储&#xff0c…

简单调试 Python 程序

From: http://www.vpsee.com/2009/09/debug-python-programwith-pdb/ 在 Python 中也可以像 gcc/gdb 那样调试程序&#xff0c;只要在运行 Python 程序时引入 pdb 模块&#xff08;假设要调试的程序名为 d.py&#xff09;&#xff1a; $ vi d.py #!/usr/bin/pythondef main():…

css3修改input[type=radio]样式

在项目中经常&#xff0c;需要使用单选按钮input[typeradio]&#xff0c;但是浏览器的默认样式可能与我们需要实现的样式差距很大&#xff0c;可以使用css3来实现想要达到的效果&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta cha…

我们应当学会辞旧迎新——《不一样的天空》

乏味的人生&#xff0c;冷清的家庭&#xff0c;枯燥的工作&#xff0c;基本上是现代社会中大部分人的心声&#xff0c;随着时间的流逝&#xff0c;逐渐失去自我&#xff0c;沦为生活的奴隶。而这部电影也以同样的道理告诫我们&#xff0c;不要被一层不变的生活模式所吞噬&#…

在移动端a、input、label等标签点击后会出现背景阴影问题

解决方法&#xff1a; 将a,input,label{-webkit-tap-highlight-color:rgba(255,0,0,0);} 背景设置成透明的就解决了。

【leetcode】Search for a Range

题目描述&#xff1a; Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithms runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. For example…

Taro+react开发(58) toHtml

<View className"que_header_title"><RichText nodes{helpDetail.content}></RichText>{/* <Text className"que_header_title_text">{helpDetail.content}</Text> */}</View>

Python的函数参数传递:传值?引用?

From: http://blog.csdn.net/winterttr/article/details/2590741 作者&#xff1a;winterTTr &#xff08;转载请注明&#xff09; 我想&#xff0c;这个标题或许是很多初学者的问题。尤其是像我这样的对C/C比较熟悉&#xff0c;刚刚进入python殿堂的朋友们 。C/C的函数参数的传…

linux常见紧急情况处理

1&#xff0e;使用急救盘组进行维护急救盘组&#xff08;也称为boot/root盘组&#xff09;&#xff0c;是系统管理员必不可少的工具。用它可以独立地启动和运行一个完整的Linux系统。实际上&#xff0c;急救盘组中的第2张盘上就有一个完整的Linux系统&#xff0c;包括root文件系…

Python 去除列表中重复的元素

From: http://www.cnblogs.com/infim/archive/2011/03/10/1979615.html 比较容易记忆的是用内置的set l1 [b,c,d,b,c,a,a]l2 list(set(l1))print l2还有一种据说速度更快的&#xff0c;没测试过两者的速度差别l1 [b,c,d,b,c,a,a]l2 {}.fromkeys(l1).keys()print l2这两种都…

[MODX] 2. Chunks $

Chunk in Modx can cut your template into samll pieces to make code reuseable. [[$chunk_name]] For example we can replace the html header with [[$html_header]], it should work as before. 转载于:https://www.cnblogs.com/Answer1215/p/4174762.html

React开发(149):二位数组的使用

二维数组的定义 <!DOCTYPE html> <html><head><meta charset"UTF-8"><title></title></head><body><script type"text/javascript">// 定义一维数组var arr1 [1,2,3,4]var arr2 [5,6,7,8]var ar…

田志刚:个人掌握知识的精髓

【编者按】很多人都在抱怨找不到自己的竞争力&#xff0c;不知道该如何与别人竞争&#xff1b;也有很多人眼睁睁的看着同部门其他同事业绩比自己高一大截&#xff0c;却非常迷茫的找不到差距……这些问题都是切实存在的&#xff0c;而且基本上在每个人身上都曾出现过&#xff0…

【转载】async await 的前世今生(Updated)

async 和 await 出现在C# 5.0之后&#xff0c;给并行编程带来了不少的方便&#xff0c;特别是当在MVC中的Action也变成async之后&#xff0c;有点开始什么都是async的味道了。但是这也给我们编程埋下了一些隐患&#xff0c;有时候可能会产生一些我们自己都不知道怎么产生的Bug&…

H5页面移动端双击屏幕禁止页面放大

在meta标签中加入user-scalableno属性 <meta name"viewport" content"widthdevice-width,initial-scale1,maximum-scale1,minimum-scale1,user-scalableno" />

在C语言中巧用正则表达式

From: http://blog.chinaunix.net/space.php?uid20435679&doblog&id1680220 标准的C和C都不支持正则表达式&#xff0c;但有一些函数库可以辅助C/C程序员完成这一功能&#xff0c;其中最著名的当数Philip Hazel的Perl-Compatible Regular Expression库&#xff0c;许多…

[笑]每个人都有脑袋脱线的时候……

每个人的脑子在一霎间短路时会做出好笑的事情来&#xff0c;我也是&#xff0c;不过现在让我想还真想不起来&#xff0c;只是在看到下面这篇文章时心里会有似曾相识的感觉&#xff0c;转来让大家感受一下&#xff1a;洗衣服时想吐痰&#xff0c;旁边是马桶&#xff0c;结果一口…

Taro+react开发(60) 第三方icon使用

<AtIconprefixClass"icon"value{isLike true ? "icon-like-select" : "icon-like-default"}size"14"color{isLike true ? "#FF7F00" : "#999"}onClick{() > this.handleIsLike()}></AtIcon>

middlegenidenbsp;nbsp;eclipsenbsp;的插件

eclipse 的插件很好安装的.拖进eclipse的文件夹.加到plugins和features里. 加到eclipse jee里..没反应. 只好加到eclipse j2se里. 可以的. 重要的是这个 学校发的书说只有oracle需要设category和schema. 坑人. 说只就要严谨些 之后的就不用说了 转载于:https://www.cnblog…