CSS自定义文件上传按钮样式,兼容主流浏览器

1. [代码][HTML]代码

1 <div class="box">
2      <input type="text" name="copyFile"  class="textbox" />
3      <a href="javascript:void(0);"  class="link">浏览</a>
4      <input type="file" class="uploadFile" name="upload"
5      onchange="getFile(this,‘copyFile‘)" />
6 </div>

2. [代码][CSS]代码

 1 <style type="text/css">
 2     * {
 3         margin:0;
 4         padding:0;
 5     }
 6     body {
 7         font:14px Verdana, Arial, Geneva, sans-serif;
 8         color:#404040;
 9         background:#fff;
10     }
11     img {
12         border-style:none;
13     }
14     .main{
15         width:300px;
16         height:60px;
17         position:absolute;
18         left:50%;
19         top:50%;
20         margin-left:-150px;
21         margin-top:-30px;
22     }
23     .box{
24         position:relative;
25         float:left;
26     }
27     input.uploadFile{
28         position:absolute;
29         right:0px;
30         top:0px;
31         opacity:0;
32         filter:alpha(opacity=0);
33         cursor:pointer;
34         width:276px;
35         height:36px;
36         overflow: hidden;
37     }
38     input.textbox{
39         float:left;
40         padding:5px;
41         color:#999;
42         height:24px;
43         line-height:24px;
44         border:1px #ccc solid;
45         width:200px;
46         margin-right:4px;
47     }
48     a.link{
49         float:left;
50         display:inline-block;
51         padding:4px 16px;
52         color:#fff;
53         font:14px "Microsoft YaHei", Verdana, Geneva, sans-serif;
54         cursor:pointer;
55         background-color:#0099ff;
56         line-height:28px;
57         text-decoration:none;
58     }
59 </style>
时间: 2024-12-30 05:22:26

CSS自定义文件上传按钮样式,兼容主流浏览器的相关文章

CSS自定义文件上传按钮

原文:CSS自定义文件上传按钮 今天一同事问我文件上传按钮的问题,情况是这样的,他页面上有3个按钮,分为左中右三个,左边的位按钮甲,右边的位按钮乙,而中间的就是个文件选择按钮,情况大概是这个样子的: 两边的按钮都有了样式,但中间的选择文件的样式死活调不出来,于是我就同他一块解决,后来经过自己设置width,height折腾无果,再求助google终于找到了解决办法,这个方法是这样的: 用一个标签套着文件域,然后调整文件域外边的元素,设置成按钮样式,然后,在把文件域"隐藏"掉(这里的隐藏

文件上传按钮的用户自定义样式的实现

一般在做 WEB 开发项目的时候碰到文件上传必不可少,但是因为各家浏览器对于 <input type="file"> 标签支持不同所以在各个浏览器下的显示也是不一样的.可能在用户体验方面会形成困扰,今天就给大家介绍一下文件上传按钮的用户自定义样式的实现. 实现原理: 建立两个层,一个层包装 <input type="file"> 以下简称文件按钮层,一个层包装上传文件按钮的自定义样式,以下渐层样式层.设置两个层的大小一致,将文件按钮层设置相对

文件上传下载样式 --- bootstrap

在平时工作中,文件上传下载功能属于不可或缺的一部分.bootstrap前端样式框架也使用的比较多,现在根据bootstrap强大的样式模板,自定义一种文件下载的样式. 后续会使用spring MVC框架实现文件上传的全部代码,敬请期待. 先看图片示例: 本示例包括下载样本文件样式和上传文件样式. 直接先上代码,最后讲解: <div class="form-group col-md-12 has-feedback" id="file"> <label

ExtJs4学习(十三)如何给文件上传按钮加背景图片

我们日常看到的上传按钮都是这样的 当然browse是默认的,我们可以去改变它,比如替换成"上传",配置为buttonText: '上传', 如果我们想给按钮添加背景图片呢,你可能注意到了这个配置 buttonConfig { xtype: 'filefield', emptyText: 'Select an image', fieldLabel: 'Photo', name: 'photo-path', buttonText: '', buttonConfig: { iconCls:

文件上传按钮input[type=&quot;file&quot;]按钮美化时在IE8中的bug【兼容至IE8】

首先看一下完成后的效果,鼠标移入可改变为手指的效果. 在此就不加图标了 <label class="file-upload"> <span>上传附件</span> <input type="file" name=""> </label> 在IE8中需要将input透明后还不能完全达到效果,还需要将字体设大一些,撑开input,这是IE自带的兼容问题. .file-upload{ disp

input按钮上传按钮样式

主要是定位和不透明度来实现: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> /*a upload */ .a-upload { padding: 4px 10px; height: 20px; line-height: 20px; posit

上传按钮样式优化 &lt;input type=&quot;file&quot;&gt;

<html><head><title>test</title> <style>.form-element-file-wapper { position: relative; width: 100px; height: 32px; overflow: hidden; margin: 0 auto;} .form-element-file-wapper button { width: 100px; height: 32px; background-c

解决文件上传插件Uploadify在火狐浏览器下,Session丢失的问题

因为在火狐浏览器下Flash发送的请求不会带有cookie,所以导致后台的session失效. 解决的方法就是手动传递SessionID到后台. $("#fileresultfiles").uploadify({ swf: '/Scripts/uploadify/uploadify.swf', uploader: '/UploadFiles.ashx', queueID: 'fileQueue', buttonText: '附件上传', auto: true, debug: false

javascript创建css、js,onload触发callback兼容主流浏览器的实现

http://www.fantxi.com/blog/archives/load-css-js-callback/ 由于需要写个函数,既可以加载css,又可以加载js,所以对各主流浏览器对加载js.css后是否触发onload事件做了个测试.当然,为了兼容,首先要考虑的是会用到onload和onreadystatechange,但他们并不是万能的.加载js文件onload触发callback不算大问题.css比较特殊,因为Webkeit/FF下加载css不会触发onload事件.所以研究了一晚上