zoukankan      html  css  js  c++  java
  • 点击之后上传图片到页面 input type="file" 样式


    <!DOCTYPE html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test js</title>
    <style>
    #pic{
    100px;
    height:100px;
    border-radius:50% ;
    margin:20px auto;
    cursor: pointer;
    }
    .upfile{
    /*opacity: 0;*/
    }
    .file {
    position: relative;
    display: inline-block;
    background: #D0EEFF;
    border: 1px solid #99D3F5;
    border-radius: 4px;
    padding: 4px 12px;
    overflow: hidden;
    color: #1E88C7;
    text-decoration: none;
    text-indent: 0;
    line-height: 20px;
    }
    .file input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
    }
    .file:hover {
    background: #AADFFD;
    border-color: #78C3F3;
    color: #004974;
    text-decoration: none;
    }

    </style>
    </head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>


    <body>

    <div class="img_show img_show1">
    <p class="p-flex">
    <span class="vertical-blue"></span><span class="left-A" >水印设置</span>
    <img src="" alt="" class="img-big" width="103" height="103">
    <img src="" alt="" class="img-centre" width="103" height="103">
    <img src="" alt="" class="img-small" width="103" height="103" >
    </p>
    <p class="text-blue">
    <a href="javascript:;" class="file">上传水印
    <input type="file" class="upfile" value="更换" class="changes" accept="image/*">
    </a>
    </p>
    </div>

    </body>
    <script>
    upfile = function(){
    $('.img_show').each(function(){
    var $this = $(this),
    btn = $this.find('.upfile'),
    img = $this.find('img');
    btn.on('change',function(){
    var file = $(this)[0].files[0],
    imgSrc = $(this)[0].value,
    url = URL.createObjectURL(file);
    if (!/.(jpg|jpeg|png|JPG|PNG|JPEG)$/.test(imgSrc)){
    alert("请上传jpg或png格式的图片!");
    return false;
    }else{
    img.attr('src',url);
    img.css({'opacity':'1'});
    }
    });
    });
    }();
    </script>
    </html>

  • 相关阅读:
    asp.net Core 中间件Hello world
    MVC2 ,MVC3 ,MVC4,MVC5的区别,EF的各个版本的区别;LocalDB是个啥
    EF6 MVC5译文
    发布一个C++版本的ORM库SmartDB
    ORM
    Git图形化界面客户端大汇总
    Model工具
    HTTP协议的8种请求类型介绍
    五大主流数据库模型
    店铺装修——进阶模块介绍
  • 原文地址:https://www.cnblogs.com/zouyun/p/7944241.html
Copyright © 2011-2022 走看看