[英]Why does a button element's height not match that of a sibling input element with same height properties?
我有以下內容:
<div style="border:solid 1px gray; height:22px; line-height:22px; display:inline-block;">Div</div>
<input style="border:solid 1px gray; height:22px; line-height:22px; vertical-align:top;" type="text">
<button style="border:solid 1px gray; height:22px; line-height:22px; vertical-align:top;">Button</button>
它與瀏覽器實現這些元素的盒子模型的方式有關。
div
和input
都使用content-box
where-as button
使用border-box
有關詳細信息,請參閱此處: http : //www.quirksmode.org/css/box.html
您可以添加box-sizing: content-box;
, -moz-box-sizing: content-box;
, -ms-box-sizing: content-box;
到CSS強制它使用計算維度的內容框方法。
編輯 - 更多信息 : 為什么Firefox使用IE框模型作為輸入元素?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.