p?? img ???? ? ?? ??? ????.
1. p?? ?? ??:0px
?? ????car1.html? ???? ????? 0.
2. p? ? ?? ??? ?? ??:0px
? ?????. ????car2.html? ???? ?? ??? 6px???.
? ??? ??? ??????
走同樣的路,發(fā)現(xiàn)不同的人生
img ??? ?? ?? ?????. img ??? ???? ?? ???? p ?? ??? ??? ??? ??? ????. ??? ???? ??? img?? ?? ??? ??? ? ????. e1? e2? ?? ??? img? p ??? ?????. (?? ???? ?? ???? ??, p ?? ??:0? ???? e1-e2? 0? ? ? ????.)
? ?? ??: ?? 1? 2? ??? ???
3?:
1 p? ??? line-height
?? ?????. line-height
撐起。
2.默認(rèn)情況下,line-height
為normal
(1.1-1.2由瀏覽器決定),又是由font-size
決定
3.offsetHeight
還包括border
所以,我們?cè)賮砜矗?br>情況1:在父元素p
設(shè)置font-size:0
;此時(shí),span
繼承font-size:0
,但border
上下和2px,所以,p
的offsetHeight
=內(nèi)容高度+border
,內(nèi)容高度=img
的offsetHeight
+span
的2px,所以e1.offsetHeight-e2.offsetHeight=2
才對(duì)
情況2:在子元素上分別設(shè)置font-size:0
;img
和span
的情況和上述一樣,但是p
的font-size
默認(rèn)為16px
;line-height
2. ????? line-height
? normal
(1.1-1.2? ????? ?? ???)?? font-size??
offsetHeight
?? ???
#????#? ?????.
#????#??? ?? ???????. #????#?? 1: ?? ?? ?? p
? font-size:0
? ?????. code>spanfont-size:0
? ????? border
? ??? ???? 2px??? offsetHeight
=? p
??? ?? + ???
, ??? ?? = img
? offsetHeight
+ span
2px??? e1.offsetHeight-e2.offsetHeight=2
? ?????#????#Case 2: font-size:0
;img ?? ?? ??? ?? code> ? span
? ??? ?? ????? p
? font-size
? ????? 16px
;line-height ?? ????? ?? ????? ??? ?? ???? ?? ?? ????? ?? ?????. #????#