zoukankan      html  css  js  c++  java
  • 美化type="file"控件

    对于type="file"而言是一个不大好看的控件。如果不美化他一下,总感觉自己的网站有些缺乏了美感

    上代码:

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>定义input type="file" 的样式</title>
    <style type="text/css">
    body{ font-size:14px;}
    input{ vertical-align:middle; margin:0; padding:0}
    .file-box{ position:relative;340px}
    .txt{ height:22px; border:1px solid #cdcdcd; 190px;}
    .btn{ background-color:#FFF; border:1px solid #CDCDCD;height:24px; 70px; }
    .file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;260px }
    </style>
    </head>
    <body>
    <div class="file-box">
      <form action="" method="post" enctype="multipart/form-data">
     <input type='text' name='textfield' id='textfield' class='txt' />  
     <input type='button' class='btn' value='浏览...' />
    
        <input type="file" name="fileField" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />
     <input type="submit" name="submit" class="btn" value="上传" />
      </form>
    </div>
    </body>
    </html>

    样式说明:

     上面的是用了一个text和一个按钮去伪装成了一个type="file"控件;实则控件本身为隐藏状态;

       而怎么实现点击即点控件,就用到了绝对定位

    filter:alpha(opacity:0);opacity: 0; 前者是适合ie8一下的浏览器用于过滤用的,后者用现在的很多的浏览器。这个值趋近于0基本就是透明状态了

  • 相关阅读:
    夺命雷公狗TP3.2.3商城11-----后台头部和左侧导航分离
    夺命雷公狗TP3.2.3商城10-----中间层的创建,防止跨目录访问
    3.spring cloud eureka 高可用
    2.spring cloud eureka client配置
    1.spring cloud eureka server配置
    css去掉input记住密码的黄色
    34-THREE.JS 游泳圈
    32-THREE.JS 球体
    31-THREE.JS 正方体
    30-THREE.JS 圆环
  • 原文地址:https://www.cnblogs.com/yaobolove/p/6044674.html
Copyright © 2011-2022 走看看