zoukankan      html  css  js  c++  java
  • 修改选择文件按钮,变成自己设置的样式

    1.所达到的效果:

    2.思想:

    (1)将选择文件的按钮与自己写的按钮重合;此处关键在于fileop的float:left;和left:40px;

    (2)将选择文件的按钮设置透明化。

    <style type="text/css">
            *{
                margin:0;
                padding:0;
                font-size:14px;
            }
            .fileop{
                width:105px;
                height:30px;
                opacity:0;/*透明化  */
                float:left;
                z-index:3;
                position:absolute;
                left:40px;/*将原来的选择文件的按钮设置透明化,在不断的移动,使之与按钮重合  */
            }
             .xzwjbtn{
                 float:left;
                 border-radius:3px;
                 height:25px;
                 line-height:36px;
                 margin-left:10px;
                 background-color:#3379d8;
                 cursor:pointer;
                 align:center;
                 width:100px;
             } 
        </style>
    <div class="selfile" style="margin-top:30px;margin-left:31px;">
          <input type="file" id="fileop" name="file" multiple="true" class="fileop" />
          <a id="xzwjbtn" href="javascript:void(0)" class="easyui-linkbutton xzwjbtn">选择文件</a>
          <input type="text" id="filete" name="filename" class="easyui-validatebox xzwj" style="180px;height:25px;margin-left:10px;padding-left:5px;" readonly="true"/>
      </div>

     一定要进行以下操作,才能把选择的文件填入到后面的输入框中

    <script type="text/javascript">
    	$(document).ready(function(){
    		$("#fileop").change(function(){
    			var selname=$(this).val();
    			var str="fakepath";
    			var hhstr="";
    			if(selname.indexOf(str)>=0){
    				hhstr=selname.substring(12,selname.length);
    				$("#filete").val(hhstr);
    			}else{
    				$("#filete").val(selname);
    			}
    		});
    	});
    	</script>
    

    效果:

      

  • 相关阅读:
    select poll使用
    linux下tomcat shutdown后 java进程依然存在
    poj 1222 EXTENDED LIGHTS OUT(高斯消元)
    poj 2377 Bad Cowtractors
    C#:总结页面传值几种方法
    从 Racket 入门函数式编程
    程序猿接私活经验总结,来自csdn论坛语录
    什么是SEO?SEO干嘛的?怎么做SEO?
    Java设计模式-观察者模式
    非常特别的一个动态规划新手教程
  • 原文地址:https://www.cnblogs.com/GumpYan/p/7601751.html
Copyright © 2011-2022 走看看