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基本就是透明状态了

  • 相关阅读:
    卷积神经网络入门(1) 识别猫狗
    lumen 获得当前uri 如/xxx/{id}
    React ES5 (createClass) 和 ES6 (class)
    lumen 单元测试
    mysql 高级语法手记
    react手记(componentWillMount,componentDidMount等)
    lumen 事件
    PDO drivers no value in Windows
    BindingNavigator操作DatagridView的数据
    <input type="hidden" id="haha" name="wang" value="xiaodong" />
  • 原文地址:https://www.cnblogs.com/yaobolove/p/6044674.html
Copyright © 2011-2022 走看看