網(wǎng)頁前端開發(fā)-控制input輸入框的高度
2013/3/8 14:16:35來源:百度泛用戶體驗
輸入框高度
<input style="height: 28px;" type="text" />
- IE6(xp)
- IE7(xp)
- IE8(win7)
- Firefox 3.5(xp)
- Firefox 3.5(win7)
- Firefox 3.5(mac 10.6.2)
- Firefox 3.5(ubuntu 10.4)
- Chrome 5(xp)
- Chrome 5(win7)
- Chrome 5(mac 10.6.2)
- Chrome 5(ubuntu 10.4)
通過設(shè)定height的方式
<input style="font: 16px arial; height: 1.78em; padding-top: 2px;" type="text" />
瀏覽器 | height + padding-top + padding-bottom + border-top-width + border-bottom-width |
---|---|
IE6(xp) | 21 + 2 + 1 + 2 + 2 = 28 |
IE7(xp) | 21 + 2 + 1 + 2 + 2 = 28 |
IE8(win7) | 21 + 2 + 1 + 2 + 2 = 28 |
Firefox 3.5(xp) | 21 + 2 + 1 + 2 + 2 = 28 |
Firefox 3.5(win7) | 23 + 2 + 1 + 1 + 1 = 28 |
Firefox 3.5(mac 10.6.2) | 19 + 2 + 1 + 3 + 3 = 28 |
Firefox 3.5(ubuntu 10.04) | 19 + 2 + 1 + 3 + 3 = 28 |
Chrome 5(xp) | 21 + 2 + 1 + 2 + 2 = 28 |
Chrome 5(win7) | 21 + 2 + 1 + 2 + 2 = 28 |
Chrome 5(mac 10.6.2) | 21 + 2 + 1 + 2 + 2 = 28 |
Chrome 5(ubuntu 10.04) | 21 + 2 + 1 + 2 + 2 = 28 |
瀏覽器 | height + padding-top + padding-bottom + border-top-width + border-bottom-width |
---|---|
IE6(xp) | 28 + 2 + 1 + 2 + 2 = 35 |
IE7(xp) | 28 + 2 + 1 + 2 + 2 = 35 |
IE8(win7) | 28 + 2 + 1 + 2 + 2 = 35 |
Firefox 3.5(xp) | 28 + 2 + 1 + 2 + 2 = 35 |
Firefox 3.5(win7) | 28 + 2 + 1 + 1 + 1 = 32 |
Firefox 3.5(mac 10.6.2) | 28 + 2 + 1 + 3 + 3 = 37 |
Firefox 3.5(ubuntu 10.04) | 28 + 2 + 1 + 3 + 3 = 37 |
Chrome 5(xp) | 28 + 2 + 1 + 2 + 2 = 35 |
Chrome 5(win7) | 28 + 2 + 1 + 2 + 2 = 35 |
Chrome 5(mac 10.6.2) | 28 + 2 + 1 + 2 + 2 = 35 |
Chrome 5(ubuntu 10.04) | 28 + 2 + 1 + 2 + 2 = 35 |
padding的方式
<input style="font: 16px arial; padding: 3px;" type="text" />
瀏覽器 | height + padding-top + padding-bottom + border-top-width + border-bottom-width |
---|---|
IE6(xp) | 18 + 3 + 3 + 2 + 2 = 28 |
IE7(xp) | 18 + 3 + 3 + 2 + 2 = 28 |
IE8(win7) | 18 + 3 + 3 + 2 + 2 = 28 |
Firefox 3.5(xp) | 19 + 3 + 3 + 2 + 2 = 29 |
Firefox 3.5(win7) | 19 + 3 + 3 + 1 + 1 = 27 |
Firefox 3.5(mac 10.6.2) | 20 + 3 + 3 + 3 + 3 = 32 |
Firefox 3.5(ubuntu 10.04) | 19 + 3 + 3 + 3 + 3 = 31 |
Chrome 5(xp) | 19 + 3 + 3 + 2 + 2 = 29 |
Chrome 5(win7) | 19 + 3 + 3 + 2 + 2 = 29 |
Chrome 5(mac 10.6.2) | 18 + 3 + 3 + 2 + 2 = 28 |
Chrome 5(ubuntu 10.04) | 19 + 3 + 3 + 2 + 2 = 29 |
瀏覽器 | height |
---|---|
IE6(xp) | 16 |
IE7(xp) | 16 |
IE8(win7) | 16 |
Firefox 3.5(xp) | 16 |
Firefox 3.5(win7) | 16 |
Firefox 3.5(mac 10.6.2) | 16 |
Firefox 3.5(ubuntu 10.04) | 16 |
Chrome 5(xp) | 16 |
Chrome 5(win7) | 16 |
Chrome 5(mac 10.6.2) | 16 |
Chrome 5(ubuntu 10.04) | 16 |
box-sizing
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; height: 28px; *height: 22px;
Browser | Lowest Version | Support of |
---|---|---|
Internet Explorer | 8.0 | box-sizing |
Firefox (Gecko) | 1.0 (1.0) | -moz-box-sizing |
Opera | 7.0 | box-sizing |
Safari (WebKit) | 3.0 (522) | -webkit-box-sizing |
padding-top: 0; padding-bottom: 0; height: 28px; *height: 24px;
瀏覽器在quirks下的實現(xiàn)方法
int RenderBox::calcContentBoxHeight(int height) const { if (style()->boxSizing() == BORDER_BOX) height -= (borderTop() + borderBottom() + paddingTop() + paddingBottom()); return max(0, height); }
/* * Quirk: Use border-box box sizing for text inputs, password inputs, and * textareas. (b=184478 on why we use content-box sizing in standards mode) */ /* Note that all other <input />s already use border-box sizing, so we're ok with this selector */ input:not([type=image]), textarea { -moz-box-sizing: border-box; }
/* This will apply only to text fields, since all other inputs already use border box sizing */ input:not([type=image]), textarea { -webkit-box-sizing: border-box; }
one more thing
結(jié)論
[教程作者:admin]
免責(zé)聲明:本站文章系圖趣網(wǎng)整理發(fā)布,如需轉(zhuǎn)載,請注明出處,素材資料僅供個人學(xué)習(xí)與參考,請勿用于商業(yè)用途!
本文地址:http://m.likemindfilms.com/tutorial/wd1384.html
本文地址:http://m.likemindfilms.com/tutorial/wd1384.html
這些是最新的
最熱門的教程