码迷,mamicode.com
首页 > 其他好文 > 详细

当input中的type值为file时,各浏览器的表现形式不同

时间:2017-09-27 21:01:29      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:nbsp   图片   button   color   upload   浏览器   back   line   相同   

如果想使各浏览器下的表现形式相同,需要对该input元素隐藏,然后再改元素下方添加标签。其html写法如下

<div class="input-file">
<input  type="file" name="postImg" value="上传图片" id="upload" class="file-button">
<label class="file-button-img">上传封面</label>
</div>

 

css布局如下

 

.input-file{
	display: inline-block;
	height:50px;
	width: 120px;
	/*background-color: #56F06F;*/
	text-align: center;
	cursor: pointer;
	position:relative;
}

.file-button{
	opacity: 0;
	position: absolute;
	left:0;
	top:0;
	width:120px;
	height: 50px;

}

.file-button-img{
	line-height: 50px;
	text-align: center;
	display: inline-block;
	margin-top: 5px;
	color:#fff;
	font-size: 18px;
	width:100%;
	height:100%;
	display: block;
	cursor:pointer;
	background-color: #3EF5B1;
}

当input中的type值为file时,各浏览器的表现形式不同

标签:nbsp   图片   button   color   upload   浏览器   back   line   相同   

原文地址:http://www.cnblogs.com/earnest/p/7603444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!