样式一(http://www.cnblogs.com/jason-liu-blogs/archive/2013/06/13/3133377.html

<style>
a{display:inline-block; width:100px; height:40px; background:red; position:relative; overflow:hidden;}
a:hover{background:green;}
input{position:absolute; right:; top:; font-size:100px; opacity:; filter:alpha(opacity=);}
</style> <a href="#">
<input type="file" value="浏览" />
</a>

外观一

样式二(http://www.jb51.net/css/69093.html

CSS 代码
*{margin:;padding:;}
a{text-decoration:none;}
.btn_addPic{
display: block;
position: relative;
width: 140px;
height: 39px;
overflow: hidden;
border: 1px solid #EBEBEB;
background: none repeat scroll #F3F3F3;
color: #;
cursor: pointer;
text-align: center;
}
.btn_addPic span{display: block;line-height: 39px;}
.btn_addPic em {
background:url(http://p7.qhimg.com/t014ce592c1a0b2d489.png) 0 0;
display: inline-block;
width: 18px;
height: 18px;
overflow: hidden;
margin: 10px 5px 10px ;
line-height: 20em;
vertical-align: middle;
}
.btn_addPic:hover em{background-position:-19px ;}
.filePrew {
display: block;
position: absolute;
top: ;
left: ;
width: 140px;
height: 39px;
font-size: 100px; /* 增大不同浏览器的可点击区域 */
opacity: ; /* 实现的关键点 */
filter:alpha(opacity=);/* 兼容IE */
} HTML代码
<A class=btn_addPic href="javascript:void(0);"><SPAN><EM>+</EM>添加图片</SPAN> <INPUT class=filePrew title=支持jpg、jpeg、gif、png格式,文件小于5M tabIndex= type=file size= name=pic></A>

外观二

样式三(http://www.360doc.com/content/12/1229/13/11395036_256962485.shtml

HTml 代码

  <div class="fileInputContainer">
<input type="file" name="fileData" id="imgFlie" onchange="showPicture(this.files)" multiple />
</div> CSS代码
.fileInputContainer {
height: 80px;
background: url(http://wx115.cnpsim.com/Content/images/imagefile.png);
background-size: contain;
position: relative;
width: 80px;
text-align:center;
}
#imgFlie {
height: 80px;
overflow: hidden;
font-size: 100px;
position: absolute;
right: ;
top: ;
opacity: ;
filter: alpha(opacity=);
cursor: pointer;
}

样式三

*可以通过JQ注册change事件以便获取选择的文件或图片,在chang事件里面通过 this.files获取选择的文件等,也可像样式三代码中一样通过JS中onchange事件获取,

*有时text-align:center,并不能使其居中时可以尝试用margin-left:30%;margin-right:30%;

 

$("#imgFlie").live("change", function () {
var data = this.files;
//var data = document.getElementById('imgFlie').files;js获取
$(this).clone().replaceAll(file = this); //每次选中都保存旧元素,并使用新的控件替换(解决紧邻的二次不能选择同一图片)
$.each(data, function (key, value) {
var objUrl = getObjectURL(value);
if (objUrl) {
var img = new Image();
img.src = objUrl;
img.onload = function () {
var size = img.width + 'x' + img.height;
$("#ImageDiv").append('<figure><div>' +
'<a href=' +
'"' + objUrl + '"' +
'data-size=' +
'"' + size + '"' +
'>' +
'<img class="WorkOrderimageNew" style="height:90px;width:90px;" src=' +
'"' + img.src + '"' +
'>' +
'</a>' +
'</div>' +
'<figcaption style="display:none;">' +
'图片' +
//'<button style="float:right;" onclick=DeleteImage("' + value + '"' +
//',' +
//'"' + value + '")>删除图片(手机端需要注册触摸事件)</button> ' +
'</figcaption></figure>'
)
};
}
});
});
function showPicture(files) {
// var files = document.getElementById('imgFlie').files;
for (var i = ; i < files.length; i++) {
var file = files[i];
if (!/image\/\w+/.test(file.type)) {
return false;
}
var url = getObjectURL(file)
if (url) {
var img = new Image();
img.src = url;
img.onload = function () {
var size = img.width + 'x' + img.height;
$("#ImageDiv").append('<figure><div>' +
'<a href=' +
'"' + img.src + '"' +
'data-size=' +
'"' + size + '"' +
'>' +
'<img class="WorkOrderimageNew" style="height:40px;width:40px;" src=' +
'"' + img.src + '"' +
'>' +
'</a>' +
'</div>' +
'<figcaption style="display:none;">' +
'这是的图片名' +
'"' + file.name + '"' +
'</figcaption></figure>'
)
}
}
}
}

input file 样式以及获取选择文件方法集合的更多相关文章

  1. input file弹出框选择文件后缀限制

    在页面选择文件时的弹出框默认显示的是所有类型的文件,有时候文件太多不好选择,我们就要过滤掉不想展示的文件,这是需要用到input的accept属性,只有在type="file"才有 ...

  2. IE input file隐藏不能上传文件解决方法

    当大神们都在探讨更深层次的问题时,我还在这里转载发些肤浅的问题解决方案.罢了,为了和我一样笨的后来人. 问题: 上传文件时,用<input type="file" /> ...

  3. input file样式修改,图片预览删除功能

    本篇对input file进行了修改,改成自己需要的样式,类似验证身份上传身份证图片的功能. 效果图如下: 这里主要展示上传预览图片功能,对于删除功能的html及css写的比较粗糙,对于想要精细表现这 ...

  4. 自定义input file样式

    自定义input file样式:一般都是通过隐藏input,通过定义label来实现.这种做法要注意的是label的for属性要指定input对应的id; <!DOCTYPE html> ...

  5. input:file样式怎样修改

    问题描述: 我需要点击input:file来修改img中的图片,但是input:file样式太丑 解决办法: 给file设置透明度为0,让用户看不见他 创建新的button按钮 修改button按钮样 ...

  6. input(file)样式修改及上传文件名显示

    实现思路: a标签包裹input元素 设置a标签为上传按钮的样式,相对定位 设置input为透明,绝对定位,覆盖到a上面 效果:看到的按钮是a的样式,点击时实际是点击input元素.样式和功能都具备 ...

  7. 安装coreseek cannot find input file: src/Makefile.in 错误解决方法

    安装coreseek 出现了cannot find input file: src/Makefile.in 解决方法如下 >autoheader >automake --add-missi ...

  8. input:file onchange事件无法读取解决方法

    最近做项目,移动端的多文件上传,使用input:file读取文件 <input type='file' name='file' multiple accept='image/*' capture ...

  9. input file 无法打开手机端文件选择器

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/m0_37805167/article/details/78538044手机端对input file的 ...

随机推荐

  1. 五、MP3文件认识上的几个误区

    1.每帧播放时长都为26ms? 很多博客和文章都提到,Mp3文件每个帧的播放时长(Frame_PlayingTime)是26ms,这个结论是错误的.公式应该是这样的: 一个帧的播放时长=一个帧的采样个 ...

  2. 【转】SSIS 2012 – Package Configurations Menu Option Missing

    原文:http://dataqueen.unlimitedviz.com/2012/01/ssis-2012-package-configurations-menu-option-missing/ I ...

  3. SQL使用记录

    Q:怎么删掉sql server登录时的用户名?(仅仅是删掉那个登录时的提示) A:先关闭数据库登录引擎,然后删除:%AppData%\Microsoft\Microsoft SQL Server\1 ...

  4. 2、vector的实现

            看侯捷老师的<STL源码剖析>有一段时间了,打算自己整理一下思路,试着实现一下.主要目的有两个:1.巩固自己对源码的理解,让自己更加深刻的体会其中各种机制的奥妙.别人的知识 ...

  5. 纪念SlingShot 矩阵

    第一次独立做矩阵,只WA了一次,好高兴~~ 题意:已知 F(n)=3 * F(n-1)+2 * F(n-2)+7 * F(n-3),n>=3,其中F(0)=1,F(1)=3,F(2)=5,对于给 ...

  6. golang illegal base64 data at input byte

    //one reason is whitespace ciphertext = strings.Replace(ciphertext, " ", "", -1) ...

  7. 《javascript权威指南》阅读笔记 1

    3.1-3.5 3.1 数字 3.1首先声明了在JS中的数字是不区分整数值和浮点数值的.其次给出了js浮点类型表示的范围:最大值是±1.7976931348623157×10^308,最小值±5×10 ...

  8. DedeCms 建站随笔(一)

    站名:524社区网 代码:DedeCms织梦5.7代码(UTF-8) 服务器:Linux 问题一:火车头(熊猫)采集,登录成功之后无法获取栏目列表. 原因:1.新建栏目后没有更新栏目HTML文件,并且 ...

  9. 命令行参数解析:getopt,getopt_long

    #include <unistd.h> int getopt(int argc, char * const argv[], const char *optstring); extern c ...

  10. 1003 Crashing Balloon

    考察DFS的应用,判断两个数的因子. #include <stdio.h> int f1,f2; void DFS(int m,int n,int k){ ){ f2=; ) f1=; } ...