图标实现文件的上传下载

今天由于项目的bug再改,我写一篇博客纪念解决的小图标bug,不废话了,上代码

<!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">
    <link rel="stylesheet" href="style.css"/>
    <script src="lib/vue-2.4.0.js"></script>
    /* Vue引入*/
    <title>图标案例</title>
    <style>
        /*设置公共样式*/
        .icon {
            list-style: none;
            font-family: "icomoon";
            font-weight: normal;
            font-style: normal;
            color: #000000;
            font-size: 18px;
        }
/*第一种方法*/
        .fileinput-button {
            position: relative;
            display: inline-block;
            overflow: hidden;
        }
        .fileinput-button input {
            position: absolute;
            right: 0;
            top: 0;
            opacity: 0;
        }

    </style>
</head>
<body>
<div>
    <!--第一种方法-->
    <span class="fileinput-button ">
   <i class="icon icon-upload" aria-hidden="true"></i>
   <input type="file" multiple>
 </span>
    <!--需要css配合-->
    <!--利用定位和透明度-->

</div>
<div>
    <!--第二种-->
    <label for="fileInput">
        <i class="icon icon-upload" aria-hidden="true"></i>
    </label>
    <input v-show="false" type="file" id="fileInput" style=" opacity: 0;">
    <!--Vue方法-->
    <!--用label,之后改变input的透明度,因为透明之后会占用空间,所以加一个父级标签,设置宽度,超过之后在隐藏-->

</div>
<div>
    <label for="fileInput">
        <i class="icon icon-upload" aria-hidden="true"></i>
    </label>
    <input v-show="false" type="file" id="fileInput">
<!--第三种Vue方法-->
</div>


</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值