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

如果想使各浏览器下的表现形式相同,需要对该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;
}
时间: 2024-08-08 06:44:38

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

js下读取input中的value值

很多人(包括我),总想像以前操作js一样,读取到input中的值:document.getElementById('').value; 结果事实证明这样读到得是null. eval(document.getElementById('')).value

jquery获取input中输入的值?

$("#test").val() $("input[name='test']").val()$("input[type='text']").val()$("input[type='text']").attr("value")

【Python】如何取到input中的value值?

练习:取到下方链接下所有海贼王的下载链接. 1 # coding=utf-8 2 from selenium import webdriver 3 from time import sleep 4 import keyword 5 from selenium.webdriver.common.keys import Keys 6 from selenium.webdriver.support.wait import WebDriverWait 7 from selenium.webdriver.

《Entity Framework 6 Recipes》中文翻译系列 (14) -----第三章 查询之查询中设置默认值和存储过程返回多结果集 (转)

翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 3-6在查询中设置默认值 问题 你有这样一个用例,当查询返回null值时,给相应属性设置默认值.在我们示例中,当数据库中返回null值时,用‘0’作为YearsWorked属性的默认值. 解决方案 假设你有如图3-7所示的模型,你想通过模型查询employees.在数据库中,代表employees的表包含一可为空的YearsWorked列.该列映射到Employee实体中的YearsWork

如何用jquery获取&lt;input id=&quot;test&quot; name=&quot;test&quot; type=&quot;text&quot;/&gt;中输入的值?

如何用jquery获取<input id="test" name="test" type="text"/>中输入的值?$(" #test ").val()$(" input[ name='test' ] ").val()$(" input[ type='text' ] ").val()$(" input[ type='text' ]").attr(&quo

html5中input新增type值的使用

二狗在最近的项目以html5和webapp为主,并接触到了input新增type值的使用,下面就把这些玩意一一以实例列举出来 一:type = date:定义日期:年-月-日 input type="date"可以获取年月日的值,也可以给它的value设置自定义的值哦. 注意:如果你想给input设置你自定义的value值,自定义的值的格式 一定要和input type=date的格式 一样才行. <!doctype html> <html> <head&

input框中的value值到底是什么

value 属性为 input 元素设定值. 对于不同的输入类型,value 属性的用法也不同: type="button", "reset", "submit" - 定义按钮上的显示的文本 type="text", "password", "hidden" - 定义输入字段的初始值 type="checkbox", "radio", "

js 实时监听input中值变化

js 实时监听input中值变化 分类: Javascript2014-05-11 11:13 849人阅读 评论(0) 收藏 举报 [html] view plaincopyprint? <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>RunJS

&lt;input type=&quot;text&quot;/&gt;未输入时属性value的默认值--js学习之路

在百度ife刷题是自己的一个错误引发了我对<input type="text"/>的学习. 先贴代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>example</title> </head> <body> <label for="weather_input"