No way to control inline elements’ height

今天在 css 里遇上一个以前不曾注意的细节: 假设<a>和<img>的 border, margin 和 padding均为0,一个被<a> wrapped 的 <img> (<a><img/></a>) 比单独一个 <img/> 在 Firefox 中 render 要高 3px,在 chrome 和 ie 下也会高一些(但我未测量数值)。 实例代码 我想了很久才知道这都是因为<a>和<img>是inline elements。Inline elements 有一些特性 they flow with text. they have line-height. the element height and width is dependent on the content and will not collapse to the borders of the… Continue reading No way to control inline elements’ height

Published
Categorized as 小小草 Tagged