css修正Input标签在各种浏览器中差异

css修正Input标签在各种浏览器中差异

首先,说明一下表单标签(input、select)可能在各种浏览器中的表现差异:

1.当input或select与其他标签(例如a、label)混排时,可能出现不居中的问题。

2….混排时,外层标签不能控制表单标签。

3.input里面输入的文字行高存在差别,有空隙等等。

解析现象:
input:text特性时,
默认情况下:
1.firefox高度height为16px;IE下高度为14px;
2.字体大小为:13.3333px;
3.input存在padding值:Firefox为:padding:1px 0;IE下为:padding:1px 0 3px 0;
解决实例:如下代码:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>
<html xmlns=””>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>无标题文档</title>
<style type=”text/css”>
body {
font-family:”宋体”;
font-size:12px;
}

table {
border-collapse:collapse;
border:solid red 1px;
}
td,th {
border:solid red 1px;
height:40px;
}
label {
vertical-align:middle;
}
.inputtxt {
width:200px;
padding:0;
font-family:”宋体”;
font-size:12px;
height:15px;
line-height:15px;
vertical-align:middle;
border:solid #0000FF 1px;
}

</style>
</head>
<body>
<form action=”#” method=”post”>
<table>
<tr>
<th width=”44″>firt</th>
<td ><input name=”aj” type=”text” maxlength=”6″ class=”inputtxt” />
<label>知</label>
<input type=”text” maxlength=”6″ class=”inputtxt” /></td>
</tr>
<tr>
<th>second</th>
<td>
<input name=”bs” type=”text” maxlength=”6″ class=”inputtxt” /></td>
</tr>
</table>
</form>
</body>
</html>

这种情况下IE和firefox都一样了如下图:

css修正Input标签在各种浏览器中差异

相关文章:

你感兴趣的文章:

标签云: