[心得] input width在firefox上相容性問題
今天解了一個問題...
環境: firefox 10.0.2
程式法片段: (非全部)
<tr>
<td><input type="text" name="email" size="35px" /></td>
<td><input type="text" name="password" size="160px" /></td>
</tr>
發生的情況:
a電腦: 欄位的寬度正常。
b電腦: 欄位的寬度竟然特別長,看起來比a電腦的寬度還要長。
有懷疑是不是解析度的問題,因為正常的電腦a不是用寬螢幕,
而出問題的b電腦是用寬螢幕。
儘管如此,我尚未很確切驗證我的想法對不對。
解決方法:
找了一下網路上解法,
http://www.w3schools.com/tags/att_input_size.asp
發現使用input標籤時,有段相容性說明:
Since the size attribute is a visual design attribute,
it is recommended to use CSS instead.
CSS syntax: <input style="width:100px" />
因此,我把程式碼改成:
<tr>
<td><input type="text" name="email" style="width:50px" /></td>
<td><input type="text" name="password" style="width:150px" /></td>
</tr>
發現把size改成css的寫法後,這樣在a電腦和b電腦上面網頁都正常了。
雖然說是解決了這個問題,但還是很好奇為什麼會發生這樣的問題,
而在其他瀏覽器上就不會。不知道有沒有人可以提供我一點意見??
謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.204.161
→
03/07 22:25, , 1F
03/07 22:25, 1F
→
03/07 22:32, , 2F
03/07 22:32, 2F
推
03/07 23:34, , 3F
03/07 23:34, 3F
→
03/08 00:42, , 4F
03/08 00:42, 4F
→
03/08 08:32, , 5F
03/08 08:32, 5F
→
03/08 08:33, , 6F
03/08 08:33, 6F
→
03/09 09:00, , 7F
03/09 09:00, 7F