css修正Input標籤在各種瀏覽器中差異

來源:互聯網
上載者:User
首先,說明一下表單標籤(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都一樣了如:

  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.