鍍金池/ 問答/HTML/ 父盒子的baseline 的位置取決于什么?

父盒子的baseline 的位置取決于什么?

vertical-align: middle實(shí)現(xiàn)的是元素盒子的垂直中點(diǎn)與父盒子的baseline加上父盒子的x-height的一半位置對(duì)齊,那么問題來(lái)了,如何確定父元素的盒子的baseline的位置?看了好多文章,都沒有解釋父元素盒子的baseline如何確定?規(guī)范也看了,可能沒看懂吧。麻煩大神解釋下,謝謝!
我看規(guī)范的結(jié)果就是,假如我們能知道父元素的baseline位置在哪里,那么vertical-align的各種方式都很好理解,可是各種博客都沒有解釋怎么確定父元素的baseline,這簡(jiǎn)直是一個(gè)死循環(huán)啊!
https://segmentfault.com/q/10... 其實(shí)跟上面這個(gè)問題類似

回答
編輯回答
萢萢糖

字母x的下邊緣(線)就是我們的基線。

圖片

2017年5月27日 16:30
編輯回答
薄荷糖

這段大概解釋了line box中基線的位置

CSS 2.1 does not define the position of the line box's baseline (i.e., the position of the strut, see below).

然后這段話說的字體之間會(huì)按基線對(duì)齊,但有也提到?jīng)]有字體的時(shí)候,行內(nèi)框的基線是strut,也就解釋了inline box基線的位置

User agent must align the glyphs in a non-replaced inline box to each other by their relevant baselines. Then, for each glyph, determine the A and D. Note that glyphs in a single element may come from different fonts and thus need not all have the same A and D. If the inline box contains no glyphs at all, it is considered to contain a strut (an invisible glyph of zero width) with the A and D of the element's first available font.

有了以上兩條,可以以知道對(duì)于行內(nèi)級(jí)元素他的parent box不論是inline box還是line box對(duì)齊都是參照strut(0寬字符)

2017年4月15日 11:35