網(wǎng)頁(yè)前端開(kāi)發(fā)-控制input輸入框的高度
2013/3/8 14:16:35來(lái)源:百度泛用戶體驗(yàn)
輸入框高度
<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)
通過(guò)設(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下的實(shí)現(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)載,請(qǐng)注明出處,素材資料僅供個(gè)人學(xué)習(xí)與參考,請(qǐng)勿用于商業(yè)用途!
本文地址:http://m.pkvc.cn/tutorial/wd1384.html
本文地址:http://m.pkvc.cn/tutorial/wd1384.html
這些是最新的
- 專訪:石墨文檔產(chǎn)品總監(jiān)羅穎
- UI設(shè)計(jì)不得不知的移動(dòng)端UI尺寸適
- 光音移動(dòng)設(shè)計(jì)規(guī)范 — 表單類
- 體驗(yàn)設(shè)計(jì)中的排序問(wèn)題
- 網(wǎng)頁(yè)設(shè)計(jì)精粹 網(wǎng)頁(yè)中那些迷人的按
- aliued:響應(yīng)式設(shè)計(jì)的現(xiàn)狀與趨勢(shì)
- 10個(gè)智能對(duì)象處理的ps技巧
- 網(wǎng)頁(yè)UI - 原子設(shè)計(jì)理論(上)
- 如何通過(guò)設(shè)計(jì)提升banner點(diǎn)擊率?
- 晉小彥視覺(jué)設(shè)計(jì)系列文章(二):全屏
最熱門的教程