摘要:用于對(duì)齊行內(nèi)水平元素,即那些屬性為或本文不考慮的元素。元素的基線取決于元素是否具有內(nèi)容有內(nèi)容,元素的基線是普通流中最后一個(gè)內(nèi)容元素的基線例如左邊那個(gè)。
原文地址:Vertical-Align: All You Need To Know
Often I need to vertically align elements side by side.
我經(jīng)常需要并排地垂直對(duì)齊元素。
CSS offers some possibilities. Sometimes I solve it with float, sometimes with position: absolute, sometimes even dirty by manually adding margins or paddings.
css提供一些解決方案。我有時(shí)使用float,有時(shí)使用position: absolute,有時(shí)甚至糟糕地手動(dòng)添加margins或paddings來(lái)解決這個(gè)問(wèn)題。
I don’t really like these solutions. Floats only align at their tops and need to be cleared manually. Absolute positioning takes the elements out of the flow so they do no longer affect their surroundings. And working with fixed margins and paddings immediately breaks things on the tiniest change.
我并不喜歡這些解決方案。Floats 只能對(duì)齊他們的tops,并且需要手動(dòng)的清除浮動(dòng)。絕對(duì)定位讓元素脫離了流,因此它們?cè)僖膊荒苡绊懼車(chē)氖挛铩J褂霉潭ǖ膍argins 和paddings會(huì)因?yàn)闃O細(xì)微的變化而打破。
But there is another player here: vertical-align. I think it deserves more credit. Ok, technically, using vertical-align for layout is a hack, since it wasn’t invented for this reason. It’s there to align text and elements next to text. Nonetheless, you can also use vertical-align in different contexts to align elements very flexible and fine-grained. The sizes of elements need not to be known. Elements stay in the flow so other elements can react to changed dimensions of those. This makes it a valuable option.
但是還有另一個(gè)解決方案在這兒:vertical-align。我認(rèn)為它值得更多的青睞。技術(shù)上來(lái)說(shuō),使用vertical-align來(lái)布局是一種hack,因?yàn)樗皇且驗(yàn)檫@個(gè)原因被發(fā)明的。它用來(lái)對(duì)齊文本和文本旁的元素。盡管如此,你也可以在不同的上下文中使用vertical-align靈活細(xì)致地對(duì)齊元素。元素的大小無(wú)需知道。元素呆在流中因此元素能夠應(yīng)對(duì)其他元素尺寸的改變。這也使得它成為一個(gè)有價(jià)值的選擇。
Peculiarities Of Vertical-AlignBut, vertical-align can be a real scumbag sometimes. Working with it can be a little frustrating. There seem to be some mysterious rules at work. For example, it might happen, that the element you changed vertical-align for doesn’t change its alignment at all, but other elements in the line do! I’m still getting dragged into the dark corners of vertical-align from time to time, tearing my hair.
但是,vertical-align有時(shí)真是一個(gè)卑鄙小人。使用它會(huì)讓人有點(diǎn)沮喪。似乎有一些神秘的規(guī)則在起作用。例如,你為了不改變它的對(duì)齊而改變?cè)氐膙ertical-align,但是其他在這一行的元素改變了。我仍然不時(shí)地被拖入vertical-align地黑暗角落,扯著我的頭發(fā)。
Unfortunately, most resources on the matter are somewhat shallow. Especially, if we want to use vertical-align for layout. They concentrate on the misconception of trying to vertical align everything inside an element. They give basic introductions into the property and explain how elements are aligned in very simple situations. They do not explain the tricky parts.
不幸的是,大多數(shù)資源在這個(gè)事情上描述地都有點(diǎn)淺。尤其是,如果我們想要使用vertical-align去布局。他們專(zhuān)注于嘗試垂直對(duì)齊一個(gè)元素內(nèi)部一切的錯(cuò)誤想法。他們對(duì)屬性作基本介紹并且解釋元素如何在簡(jiǎn)單的情況下被對(duì)齊。他們不解釋復(fù)雜的那部分。
So, I set myself the target to clarify the behavior of vertical-align once and for all. I ended up working through the W3C’s CSS specifications and playing with some examples. The result is this article.
因此,我定下目標(biāo)去徹底地理清vertical-align的行為。我最終通過(guò)W3C的CSS規(guī)范和玩一些例子結(jié)束這個(gè)事。這個(gè)結(jié)果就是這篇文章。
So, let’s tackle the rules of the game.
所以,讓我們來(lái)解決游戲規(guī)則。
Requirements To Use Vertical-Alignvertical-align is used to align inline-level elements. These are elements, whose display property evaluates to
inline,
inline-block or
inline-table (not considered in this article).
Inline elements are basically tags wrapping text.
vertical-align用于對(duì)齊行內(nèi)水平元素,即那些display屬性為inline,inline-block或inline-table(本文不考慮)的元素。
行內(nèi)元素基本上是包裹文本的標(biāo)簽。
Inline-block elements are what their name suggests: block elements living inline. They can have a width and height (possibly defined by its own content) as well as padding, a border and margin.
Inline-block元素就如他們的名字一樣:塊元素住著行內(nèi)。它們可以有一個(gè)width 和height (可能由它自己的內(nèi)容定義)以及padding、border 和margin。
Inline-level elements are laid out next to each other in lines. Once there are more elements than fit into the current line, a new line is created beneath it. All these lines have a so-called line box, which encloses all the content of its line. Differently sized content means line boxes of different height. In the following illustration the top and bottom of line boxes are indicated by red lines.
行內(nèi)水平元素緊挨著行內(nèi)其他元素放置。一旦當(dāng)前行放不下所有的元素,會(huì)在該行下面產(chǎn)生新的行。所有這些行稱(chēng)之為line box,line box包含了這一行的所有內(nèi)容。不同大小的內(nèi)容意味著不同高度的line boxes。在下圖中,line boxes的頂部和底部由紅線表示。
The line boxes trace out the field we are playing on. Inside these line boxes the property vertical-align is responsible for aligning the individual elements. So, in respect to what are elements aligned?
line boxes勾畫(huà)出我們可以玩的區(qū)域。在這些line boxes里面,屬性vertical-align負(fù)責(zé)對(duì)齊各個(gè)元素。那么,關(guān)于元素對(duì)齊的那個(gè)呢?
About Baselines and Outer EdgesThe most important reference point to align vertically is the baseline of the involved elements. In some cases the top and bottom edge of the element’s enclosing box becomes important, too. Let’s have a look where the baseline and outer edges live for each involved type of element:
垂直對(duì)齊最重要的參考點(diǎn)是所涉及元素的基線。在某些情況下,元素的包圍盒的頂部和底部邊緣也變得很重要。讓我們看看每個(gè)涉及的元素類(lèi)型的基線和外邊緣的位置:
Here you see three lines of text next to each other. The top and bottom edge of the line height is indicated by red lines, the height of the font by green lines and the baseline by a blue line. On the left, the text has a line height set to the same height as the font-size. The green and red line collapsed to one line on each side. In the middle, the line height is twice as large as the font-size. On the right, the line height is half as large as the font-size.
在這里你可以看到文本相鄰的三條線。行高的頂部和底部邊緣由紅線表示,字體的高度由綠線和基線由藍(lán)色線表示。左側(cè)的那個(gè),文本的行高設(shè)置為與字體大小相同的高度。上下兩邊綠色和紅色的線均重合為一條線。中間的那個(gè),行高是字體高的兩倍。右邊的那個(gè),行高是字體高的一半。
The inline element’s outer edges align themselves with the top and bottom edge of its line height. It does not matter, if the line height is smaller than the height of the font. So, the outer edges are the red lines in the figure above.
行內(nèi)元素的外邊緣與它的行高的頂部和底部邊緣對(duì)齊。如果行高是小于字體高,也沒(méi)有關(guān)系。所以,外邊緣是上圖中的紅線。
The inline element’s baseline is the line, the characters are sitting on. This is the blue line in the figure. Roughly speaking, the baseline is somewhere below the middle of the font’s height. Have look at the W3C Specs for a detailed definition.
行內(nèi)元素的基線是那條字符坐著的線。就是圖中的藍(lán)線。粗略地說(shuō),基線是在字體高度中間的下面的某個(gè)地方。看下W3C規(guī)范關(guān)于這個(gè)的詳細(xì)的定義。
From left to right you see: an inline-block element with in-flow content (a “c”), an inline-block element with in-flow content and overflow: hidden and an inline-block element with no in-flow content (but the content area has a height). The boundaries of the margin is indicated by red lines, the border is yellow, the padding green and the content area blue. The baseline of each inline-block element is shown as a blue line.
從左到右你可以看到:一個(gè)inline-block元素里面有in-flow內(nèi)容(一個(gè)“C”),一個(gè)inline-block元素有in-flow內(nèi)容和overflow: hidden,一個(gè)inline-block元素沒(méi)有in-flow內(nèi)容(但是內(nèi)容區(qū)域有高度)。margin的邊界由紅線表示,border為黃色,padding為綠色和內(nèi)容區(qū)域?yàn)樗{(lán)色。每個(gè)inline-block元素的基線是藍(lán)色線。
【譯注】:如果一個(gè)元素是浮動(dòng)的(float:left/right),絕對(duì)定位的(position:absolute/fixed)或者是根元素(html),那么它被稱(chēng)之為流外的元素(out-of-flow)。如果一個(gè)元素不是流外的元素,那么它被稱(chēng)之為流內(nèi)的元素(in-flow)。
The Inline-block element’s outer edges are the top and bottom edge of its margin-box. These are the red lines in the figure.
Inline-block元素的外邊緣是它的margin-box的頂部和底部邊緣。就是圖中的紅線。
The Inline-block element’s baseline depends on whether the element has in-flow content:
In case of in-flow content the baseline of the inline-block element is the baseline of the last content element in normal flow (example on the left). For this last element its baseline is found according to its own rules.
In case of in-flow content but an overflow property evaluating to something other than visible, the baseline is the bottom edge of the margin-box (example in the middle). So, it is the same as the inline-block element’s bottom edge.
In case of no in-flow content the baseline is, again, the bottom edge of the margin-box (example on the right).
Inline-block元素的基線取決于元素是否具有in-flow內(nèi)容:
有in-flow內(nèi)容,inline-block元素的基線是普通流中最后一個(gè)內(nèi)容元素的基線(例如左邊那個(gè))。對(duì)于最后一個(gè)元素,它的基線是根據(jù)它自己的規(guī)則確定位置的。
有in-flow內(nèi)容并且使用了值不是visible的overflow,基線就在margin-box的底部邊緣那個(gè)位置(例如中間那個(gè))。因此,它與inline-block元素的底部邊緣一樣。
沒(méi)有in-flow內(nèi)容,基線也是在margin-box的底部邊緣那個(gè)位置(例如右邊那個(gè))
You’ve already seen this setting above. This time I drew in the top and bottom of the line box’s text box (green, more on this below) and the baseline (blue), too. I also highlighted the area of the text elements by giving them a grey background.
你已經(jīng)看到以上設(shè)置。這一次我畫(huà)line box的文本盒(綠色,遠(yuǎn)在這下面)的頂部和底部和基線(藍(lán)色)。我還通過(guò)給他們一個(gè)灰色背景來(lái)強(qiáng)調(diào)文本元素的區(qū)域。
The line box has a top edge aligned to the top edge of the top-most element of this line and a bottom edge aligned to the bottom edge of the bottom-most element of the line. This is the box indicated by the red lines in the figure above.
line box的頂部邊緣與該行內(nèi)最高元素的頂部邊緣對(duì)齊,line box的底部邊緣與該行內(nèi)最底元素的底部邊緣對(duì)齊。line box就是上圖中紅線標(biāo)出的那部分。
The line box’s baseline is variable:
CSS 2.1 does not define the position of the line box"s baseline. — the W3C Specs
line box的基線是變量:
CSS 2.1 不定義line box基線的位置。-W3C 規(guī)范
This is probably the most confusing part, when working with vertical-align. It means, the baseline is placed where ever it needs to be to fulfil all other conditions like vertical-align and minimizing the line box’s height. It is a free parameter in the equation.
這可能是最讓人困惑的一部分。這意味著,基線被放在能夠?qū)崿F(xiàn)所有條件(像vertical-align,最小化line box的高度)的地方。它是方程中的一個(gè)自由參數(shù)。
Since the line box’s baseline is invisible, it may not immediately be obvious where it is. But, you can make it visible very easily. Just add a character at the beginning of the line in questions, like I added an “x” in the figure. If this character is not aligned in any way, it will sit on the baseline by default.
因?yàn)閘ine box的基線是不可見(jiàn)的,所以它所在的地方是不明顯的。但是,你可以讓它很容易被看到。僅需要在行的開(kāi)頭增加一個(gè)字符,就像我在圖中增加的“X”。如果這個(gè)字符沒(méi)有以任何方式對(duì)齊,它將默認(rèn)地坐在基線上。
Around its baseline the line box has what we might call its text box. The text box can simply be thought of as an inline element inside the line box without any alignment. Its height is equal to the font-size of its parent element. Therefore, the text box only just encloses the unformatted text of the line box. The box is indicated by the green lines in the figures above. Since this text box is tied to the baseline, it moves when the baseline moves. (Side note: this text box is called strut in the W3C Specs)
在它的基線周?chē)琹ine box有文本盒。文本盒可以當(dāng)做是放在line box里面的沒(méi)有任何對(duì)齊的行內(nèi)元素。它的高度等于它的父元素的字體大小。因此,文本盒只是把line box的無(wú)格式文本圍起來(lái)了。這個(gè)盒子就是上圖中用綠線標(biāo)出來(lái)的那個(gè)。因?yàn)檫@個(gè)文本盒與基線相關(guān)聯(lián),當(dāng)基線移動(dòng)時(shí),它也移動(dòng)。(注:這個(gè)文本盒在W3C規(guī)范中稱(chēng)為strut)
Phew, this was the hard part. Now, we know everything to put things into perspective. Let’s quickly sum up the most important facts:
There is an area called line box. This is the area in which vertical alignment takes place. It has a baseline, a text box and a top and bottom edge.
There are inline-level elements. These are the objects that are aligned. They have a baseline and a top and bottom edge.
唉,這是最難的部分。現(xiàn)在,我們知道一切。讓我們快速總結(jié)出最重要的事實(shí):
有一個(gè)叫做line box的區(qū)域。這是垂直對(duì)齊發(fā)生的區(qū)域。它有一條基線,一個(gè)文本盒和一個(gè)頂部和底部邊緣。
有行內(nèi)水平元素。他們是要對(duì)齊的對(duì)象。他們有一條基線和一個(gè)頂部和底部邊緣。
The Values Of Vertical-AlignBy using vertical-align the reference points mentioned in the last sentence in the list above are set into a certain relationship.
通過(guò)使用vertical-align,上面列表中最后一句中提到的參考點(diǎn)被設(shè)置成一定的關(guān)系。
Aligning the Element’s Baseline Relative To the Line Box’s Baselinebaseline: The element’s baseline sits exactly on top of the line box’s baseline.
sub: The element’s baseline is shifted below the line box’s baseline.
super: The element’s baseline is shifted above the line box’s baseline.
將元素基線相對(duì)于line box的基線對(duì)齊。
baseline:元素的基線在line box的基線頂部。
sub:元素的基線移動(dòng)到line box基線以下。
middle: The midpoint between the element’s top and bottom edge is aligned to the line box’s baseline plus half of the x-height.
將元素外邊緣相對(duì)于line box的基線對(duì)齊。
middle:元素頂部和底部?jī)烧唛g的中點(diǎn)與line box的基線加上二分之一的x-height對(duì)齊。
Aligning the Element’s Outer Edges Relative To the Line Box’s Text BoxOne could also list these two cases under aligning relative to the line box’s baseline, since the position of the text box is determined by the baseline.
text-top: The element’s top edge is aligned to the line box’s text box top edge.
text-bottom: The element’s bottom edge is aligned to the line box’s text box bottom edge.
將元素外邊緣相對(duì)于line box的文本盒對(duì)齊。
也可以將這兩種情況列在“相對(duì)于line box的基線對(duì)齊”下,因?yàn)槲谋竞械奈恢檬怯蒷ine box的基線決定的。
text-top:元素的頂部邊緣與line box的文本盒的頂部邊緣對(duì)齊。
text-bottom:元素的底部邊緣與line box的文本盒的底部邊緣對(duì)齊。
Aligning the Element’s Outer Edges Relative To the Line Box’s Outer Edgestop: The element’s top edge is aligned to the line box’s top edge.
bottom: The element’s bottom edge is aligned to the line box’s bottom edge.
將元素外邊緣相對(duì)于line box的外邊緣對(duì)齊
top: 元素的頂部邊緣與line box的頂部邊緣對(duì)齊。
bottom:元素的底部邊緣與line box的底部邊緣對(duì)齊。
The formal definition is found in, of course, the W3C Specs.
正式定義在W3C規(guī)范的這里。
We can now take a closer look at vertical alignment in certain situations. Especially, we will deal with situations where things might have gone wrong.
我們現(xiàn)在可以仔細(xì)看看在某些情況下地垂直對(duì)齊。主要地,我們將處理那些我們可能已經(jīng)錯(cuò)了的情況。
Centering an IconOne question bugging me was the following: I have an icon I want to center next to a line of text. Just giving the icon a vertical-align: middle didn’t seem to center it in a satisfying way. Have a look at this example:
一個(gè)問(wèn)題困擾著我:我有一個(gè)圖標(biāo),我想將圖標(biāo)中心和緊挨著的文本的中心對(duì)齊。僅僅給圖標(biāo)一個(gè)vertical-align: middle似乎并不能以滿意的方式居中。看下這個(gè)例子:
Centered?
Centered!
Here is the example again, but I drew in some auxiliary lines you already know from above:
仍是這個(gè)例子,但是我畫(huà)了一些輔助線。
This sheds some light on our matter. Because the text on the left isn’t aligned at all, it sits on the baseline. The thing is, by aligning the box with vertical-align: middle we are aligning it to the middle of the lower case letters without ascenders (half of the x-height). So, characters with ascenders stand out at the top.
這揭示了我們的問(wèn)題。因?yàn)樽筮叺奈谋緵](méi)有對(duì)齊,它位于基線上。事實(shí)是,通過(guò)vertical-align: middle對(duì)齊時(shí),我們將它和小寫(xiě)字母的中間對(duì)齊,并沒(méi)有和ascenders對(duì)齊(x-height的一半)。因此,字符和ascenders 站在頂部。
On the right, we take the whole area of the font and align its midpoint vertically, too. The text’s baseline shifts slightly below the line box’s baseline to achieve this. The Result is a nicely centered text next to an icon.
在右邊,我們把字體的整個(gè)區(qū)域中點(diǎn)垂直置中。文本的基線輕輕地移到了line box的基線下面來(lái)達(dá)成這個(gè)目的。這個(gè)結(jié)果是文本完美的和圖標(biāo)中心對(duì)齊。
Movement Of the Line Box’s BaselineThis is a common pitfall when working with vertical-align: The position of the line box’s baseline is affected by all elements in that line. Let’s assume, an element is aligned in such a way, that the baseline of the line box has to move. Since most vertical alignment (except top and bottom) is done relative to this baseline, this results in an adjusted position of all other elements in that line, too.
當(dāng)使用這個(gè)時(shí),這是一個(gè)常見(jiàn)的陷阱:line box的基線的位置受該行所有元素的影響。讓我們假設(shè),一個(gè)元素以這樣的方式對(duì)齊,即line box的基線必須移動(dòng)。由于大多數(shù)垂直對(duì)齊(除了top和bottom)是相對(duì)于這個(gè)基線,這導(dǎo)致在該行的所有其他元素調(diào)整位置。
Some Examples:
If there is a tall element in the line spanning across the complete height, vertical-align has no effect on it. There is no space above its top and below its bottom, that would let it move. To fulfil its alignment relative to the line box’s baseline, the line box’s baseline has to move. The short box has a vertical-align: baseline. On the left, the tall box is aligned text-bottom. On the right, it is aligned text-top. You can see the baseline jumping up taking the short box with it.
一些例子:
如果有一個(gè)高大的元素跨越整個(gè)高度線,vertical-alig對(duì)它就沒(méi)有影響。在它的上面和下方?jīng)]有讓它移動(dòng)的空間。為了實(shí)現(xiàn)相對(duì)于line box基線的對(duì)齊,line box的基線必須移動(dòng)。短框的vertical-align: baseline。左邊的那個(gè),高大的元素和text-bottom對(duì)齊。右邊的那個(gè),高大的元素和text-top對(duì)齊。你可以看到基線帶著短框一起跳躍。
The same behaviour shows up when aligning a tall element with other values for vertical-align.
當(dāng)高個(gè)的元素用vertical-align的其他值去對(duì)齊時(shí),是相同的行為。
Even setting vertical-align to bottom (left) and top (right) moves the baseline. This is strange, since the baseline shouldn’t be involved at all.
甚至設(shè)置vertical-align為bottom(left)和top(right)也會(huì)移動(dòng)基線。這是奇怪的,因?yàn)榛€不應(yīng)該涉及所有。
Placing two larger elements in a line and vertically aligning them moves the baseline where it fulfils both alignments. Then the height of the line box is adjusted (left). Adding a third element, that does not go beyond the line box’s edges because of its alignment, affects neither the line box’s height nor the baseline’s position (middle). If it does go beyond the line box’s edges, the line box’s height and baseline are adjusted, again. In this case, our first two boxes are pushed down (right).
將兩個(gè)大點(diǎn)的元素放在一行,然后垂直對(duì)齊他們使基線在符合這兩個(gè)元素對(duì)齊方式的地方。line box的高會(huì)調(diào)整(左)。增加第三個(gè)元素,它不超出line box的邊緣,因?yàn)樗膶?duì)齊方式,既不影響line box的高度也不影響基線的位置(中)。如果他超出了line box的邊緣,line box的高和基線會(huì)再次調(diào)整。在這種情況下,我們的前兩個(gè)箱子被推下來(lái)了(右)。
There Might Be a Little Gap Below Inline-Level ElementsHave a look at this setting. It’s common if you try to vertical-align li elements of a list.
看看這個(gè)設(shè)置。這是常見(jiàn)的,如果你試圖垂直對(duì)齊列表中的li元素。
As you can see, the list items sit on the baseline. Below the baseline is some space to shelter the descenders of a text. This is causing the gap. The Solution? Just move the baseline out of the way, for example by aligning the list items with vertical-align: middle:
正如您所看到的,列表項(xiàng)位于基線上。在基線下是放文本的descenders 空間。這造成了縫隙。解決的方法呢??jī)H需要移動(dòng)基線的位置,例如將列表項(xiàng)設(shè)置為vertical-align: middle。
This scenario does not occur for inline-blocks having text content, since content already moves the baseline up.
對(duì)于已經(jīng)有內(nèi)容的inline-blocks不會(huì)發(fā)生該場(chǎng)景,因?yàn)閮?nèi)容已經(jīng)將基線移上去了。
A Gap Between Inline-Level Elements Is Breaking the LayoutThis is mainly a problem of inline-level elements themselves. But since they are a requirement of vertical-align, it is good to know about this.
這是行內(nèi)水平元素的一個(gè)主要問(wèn)題。但是因?yàn)樗麄兪莢ertical-align的必備條件,所以最好知道這個(gè)。
You can see this gap in the former example between the list items. The gap comes from the white-space between inline-elements present in your mark-up. All white-space between inline-elements is collapsed into one space. This space gets in the way, if we want to place two inline elements next to each other and giving them width: 50%, for example. There is not enough space for two 50%-elements and a space. So the line breaks into two lines destroying the layout (left). To remove the gap, we need to remove the white-space, for example with html comments (right).
50% wide50% wide... and in next line50% wide50% wide
你可以看到在前面的例子中在列表項(xiàng)之間的間隙。間隙來(lái)自標(biāo)記中存在的行內(nèi)元素之間的空白。行內(nèi)元素之間的所有空白被折疊成一個(gè)空格。如果我們想將兩個(gè)行內(nèi)元素放在一起,并都給它們50%的寬度,這個(gè)空格會(huì)礙事。沒(méi)有足夠的空間放兩個(gè)50%寬的元素和一個(gè)空格。因此這一行就會(huì)破壞原有的布局變成兩行(左)。為了去掉間隙,我們需要去掉空白,例如使用html注釋?zhuān)ㄓ遥?/p> Vertical-Align Demystified
Yea, that’s it. It is not very complicated once you know the rules. If vertical-align does not behave, just ask these questions:
Where is the baseline and top and bottom edge of the line box?
Where is the baseline and top and bottom edge of the inline-level elements?
This will corner the solution to the problem.
是的,就是這樣。一旦你知道了規(guī)則,就不是很復(fù)雜了。如果vertical-align表現(xiàn)不對(duì),就問(wèn)下這些問(wèn)題:
基線,line box的頂部和底部邊緣在哪里?
基線,行內(nèi)水平元素的頂部和底部邊緣在哪里?
這將解決那個(gè)問(wèn)題。
以上翻譯如有不當(dāng)之處,請(qǐng)指正!
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/116566.html
摘要:用于對(duì)齊行內(nèi)水平元素,即那些屬性為或本文不考慮的元素。元素的基線取決于元素是否具有內(nèi)容有內(nèi)容,元素的基線是普通流中最后一個(gè)內(nèi)容元素的基線例如左邊那個(gè)。 原文地址:Vertical-Align: All You Need To Know Often I need to vertically align elements side by side. 我經(jīng)常需要并排地垂直對(duì)齊元素。 CSS ...
摘要:但如果一個(gè)組件在生命周期鉤子里改變父組件屬性,卻是可以的,因?yàn)檫@個(gè)鉤子函數(shù)是在更新父組件屬性變化之前調(diào)用的注即第步,在第步之前調(diào)用。 原文鏈接:Angular.js’ $digest is reborn in the newer version of Angular showImg(https://segmentfault.com/img/remote/146000001468785...
摘要:絕對(duì)定位讓元素脫離文檔流,所以他們不再影響他們的周邊元素。元素在文檔流中,也能感知其他元素尺寸的改變。中間,一個(gè)在文檔流中的元素并且?guī)в袑傩缘脑亍W钣遥辉谖臋n流中的元素但是內(nèi)容區(qū)域有高度。元素的基線依賴(lài)于元素是否是文檔流中的元素。 原文:Vertical-Align: All You Need To Know 通常我都有需要垂直對(duì)齊在一排上一個(gè)接著一個(gè)的元素。CSS提供了很多種可能...
摘要:前端日?qǐng)?bào)精選譯測(cè)試版本漫談前端體系建設(shè)輕松理解框架的基本原理,簡(jiǎn)單實(shí)現(xiàn)一個(gè)關(guān)鍵請(qǐng)求為什么是而不是的中文譯擴(kuò)展知乎專(zhuān)欄譯白話掘金調(diào)查報(bào)告眾成翻譯的平凡之路學(xué)習(xí)人氣眼中的效果中掘金與阻止元素被選中及清除選中的方法總結(jié)風(fēng) 2017-08-04 前端日?qǐng)?bào) 精選 【譯】React 16 測(cè)試版本漫談前端體系建設(shè)輕松理解vue框架的基本原理,簡(jiǎn)單實(shí)現(xiàn)一個(gè)todo-list關(guān)鍵請(qǐng)求為什么是displ...
Functions are first-class citizen Functions are first-class citizen in JavaScript, as the same as other types(e.g. number, array, object). They can be used as arguments, as well as return value from o...
閱讀 2181·2021-11-19 09:55
閱讀 2637·2021-11-11 16:55
閱讀 3175·2021-09-28 09:36
閱讀 1945·2021-09-22 16:05
閱讀 3270·2019-08-30 15:53
閱讀 1806·2019-08-30 15:44
閱讀 2899·2019-08-29 13:10
閱讀 1339·2019-08-29 12:30