視覺(jué)格式化模型Visual formatting model (梁王的理論自習(xí)室)(待補(bǔ)充)

前言

未完成

等我看完CSS Mastery的這一章我再回來(lái)钠四。

視覺(jué)格式化模型在干什么

現(xiàn)在我們聲明了許多個(gè)盒子和它們的margin踱阿,border透罢,padding等等,我們需要確定在屏幕上怎么去組織這些盒子虏肾,這就是CSSvisual formatting model的任務(wù)

許多個(gè)盒子 怎么去組織它們

Visual formatting model

什么是視覺(jué)格式化模型

慣例還是上MDN Visual formatting model

The CSS visual formatting model is an algorithm that processes a document and displays it on visual media. This model is a basic concept of CSS.

反正意思就是這個(gè)東西是一個(gè)算法廓啊,把一個(gè)document顯示到visual media上的算法。(注:visual media指 screens, projectors and paper之類的)

視覺(jué)格式化模型把文檔里面的每個(gè)元素(指的html里面的元素)轉(zhuǎn)化成零個(gè)封豪,一個(gè)谴轮,或多個(gè)盒子(boxes)使其符合盒模型(box model)。這些盒子的布局由以下東西決定(詳情我在盒子模型的博文里面細(xì)講):

  • 盒子的尺寸: 被精確指明或者限制或者啥也沒(méi)有說(shuō)(比如width: 200px; 或 max-width:300px; 或者啥也沒(méi)說(shuō))
  • 盒子的type: inline, inline-level, atomic inline-level, block.
  • 盒子的position: in the normal flow, a float, or absolute positioning.
  • 其他文檔樹(shù)里面的元素吹埠,childrens或者neighbors(比如父元素會(huì)被子元素?fù)伍_(kāi))
  • The viewport size and position.(比如width: 100% 還有我不知道overflow那些算不算)
  • Intrinsic dimensions of contained images. (第步?沒(méi)理解)
  • Other external information. (沒(méi)理解)

盒子的生成 (Box generation)

我們知道了盒子和視覺(jué)格式化模型有密不可分的關(guān)系疮装,盒子的生成式視覺(jué)格式化模型的一部分,它從文檔中創(chuàng)建了不同類型的盒子粘都,并影響了視覺(jué)格式化的完成廓推。盒子的類型主要由display屬性決定。

塊級(jí)元素和塊盒子(block boxes)

一個(gè)元素如果display屬性是 block,list-item 或 table我們就稱為塊級(jí)元素翩隧,而塊級(jí)元素會(huì)在垂直方向堆疊樊展。

每個(gè)塊級(jí)元素參與 塊級(jí)格式化上下文BFC. 每個(gè)塊級(jí)元素生成至少一個(gè)塊級(jí)盒子(block-level box)叫principal block-level box ,一些元素像 list-item 元素, 可能生成更多的盒子來(lái)處理bullets(我認(rèn)為說(shuō)的應(yīng)該是前面的小黑點(diǎn)) 和一些其他的印刷元素堆生。更多的還是只生成 principal block-level box.
principal block-level box 包括后代生成的盒子(應(yīng)該說(shuō)的是子元素生成的盒子)和生成的內(nèi)容(generated content). It is also the box involved in the positioning scheme.

一個(gè)塊級(jí)盒子也可以是塊容器框(block container box). 塊容器框(block container box)是一個(gè)盒子专缠,而這個(gè)盒子只塊容器框只包含塊級(jí)元素或建立IFC(inline formatting context)行內(nèi)級(jí)元素。這句話其實(shí)是塊容器框的特性顽频,而不是定義藤肢。her block-level boxes, or creates an , thus containing only inline boxes.

It is important to note that the notions of a block-level box and block container box are disjoined. The first, describes how the box behaves with its parents and sibling. The second, how it interacts with its descendants. Some block-level boxes, like tables, aren't block container boxes. Reciprocally, some block container boxes, like non-replaced inline blocks and non-replaced table cells, aren't block-level boxes.

Block-level boxes that also are block container boxes are called block boxes.

image.png

匿名塊盒子(Anonymous block boxes)

In some cases, the visual formatting algorithm needs to add supplementary boxes. Because CSS selectors cannot style or name these boxes, they are called anonymous boxes.(比如偽類里面的content還有div里面的內(nèi)容textnode)

Because selectors do not work with anonymous boxes, they cannot be styled via a stylesheet. This means that all inheritable CSS properties have the inherit value, and all non-inheritable CSS properties, have the initial value.

Block containing boxes contain only inline-level boxes, or only block-level boxes. But often the document contains a mix of both. In that case, anonymous block boxes are created around adjacent inline-level boxes.

EXAMPLE
<div>Some inline text <p>followed by a paragraph</p> followed by more inline text.</div>
image.png

Unlike the <p> element's box, Web developers cannot control the style of the two anonymous boxes. Inheritable properties take the value from the <div>'s property value, like color to define the color of the text, and set the others to the initial value. For example, they won't have a specific background-color, it is always transparent, the initial value for that property, and thus the background of the <div> is visible. A specific background color can be applied to the <p> box. Similarly, the two anonymous boxes always use the same color for their text.

Another case that leads to the creation of anonymous block boxes, is an inline box that contains one or several block boxes. In that case, the box containing the block box is split into two inline boxes: one before, and one after the block box. All the inline boxes before the block box are then enclosed into an anonymous block box, so are the inline boxes following the block box. Therefore, the block box becomes the sibling of the two anonymous block boxes containing the inline elements.

If there are several block boxes, without inline content in-between, the anonymous block boxes are created before, and after the set of boxes.

EXAMPLE

If we take the following HTML code, with <p>have display:inline and <span> have display:block :

<p>Some <em>inline</em> text <span>followed by a paragraph</span> followed by more inline text.</p>

Two anonymous block boxes are created, one for the text before the span Element (Some inline text) and one for the text after it (followed by more inline text), which gives the following block structure:

image.png

行級(jí)元素和行級(jí)盒子(Inline-level elements and inline boxes)

An element is said to be inline-level when the calculated value of its display CSS property is: inline, inline-block or inline-table. Visually, it doesn't constitute blocks of contents, but is distributed in lines with other inline-level content. Typically, the content of a paragraph with different formatting, like emphasis or images, is made from inline-level elements.
(待補(bǔ)充)

匿名行盒子

(待補(bǔ)充)

正常流太闺、浮動(dòng)糯景、絕對(duì)定位

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市省骂,隨后出現(xiàn)的幾起案子蟀淮,更是在濱河造成了極大的恐慌,老刑警劉巖钞澳,帶你破解...
    沈念sama閱讀 210,914評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件怠惶,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡轧粟,警方通過(guò)查閱死者的電腦和手機(jī)策治,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,935評(píng)論 2 383
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)兰吟,“玉大人通惫,你說(shuō)我怎么就攤上這事』彀” “怎么了履腋?”我有些...
    開(kāi)封第一講書(shū)人閱讀 156,531評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)惭嚣。 經(jīng)常有香客問(wèn)我遵湖,道長(zhǎng),這世上最難降的妖魔是什么晚吞? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,309評(píng)論 1 282
  • 正文 為了忘掉前任延旧,我火速辦了婚禮,結(jié)果婚禮上槽地,老公的妹妹穿的比我還像新娘迁沫。我一直安慰自己烹卒,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,381評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布弯洗。 她就那樣靜靜地躺著旅急,像睡著了一般。 火紅的嫁衣襯著肌膚如雪牡整。 梳的紋絲不亂的頭發(fā)上藐吮,一...
    開(kāi)封第一講書(shū)人閱讀 49,730評(píng)論 1 289
  • 那天,我揣著相機(jī)與錄音逃贝,去河邊找鬼谣辞。 笑死,一個(gè)胖子當(dāng)著我的面吹牛沐扳,可吹牛的內(nèi)容都是我干的泥从。 我是一名探鬼主播,決...
    沈念sama閱讀 38,882評(píng)論 3 404
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼沪摄,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼躯嫉!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起杨拐,我...
    開(kāi)封第一講書(shū)人閱讀 37,643評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤祈餐,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后哄陶,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體帆阳,經(jīng)...
    沈念sama閱讀 44,095評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,448評(píng)論 2 325
  • 正文 我和宋清朗相戀三年屋吨,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蜒谤。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,566評(píng)論 1 339
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡至扰,死狀恐怖鳍徽,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情渊胸,我是刑警寧澤旬盯,帶...
    沈念sama閱讀 34,253評(píng)論 4 328
  • 正文 年R本政府宣布,位于F島的核電站翎猛,受9級(jí)特大地震影響胖翰,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜切厘,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,829評(píng)論 3 312
  • 文/蒙蒙 一萨咳、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧疫稿,春花似錦培他、人聲如沸鹃两。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,715評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)俊扳。三九已至,卻和暖如春猛遍,著一層夾襖步出監(jiān)牢的瞬間馋记,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,945評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工懊烤, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留梯醒,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,248評(píng)論 2 360
  • 正文 我出身青樓腌紧,卻偏偏與公主長(zhǎng)得像茸习,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子壁肋,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,440評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容

  • 先前在學(xué)習(xí)CSS float時(shí)号胚,有同學(xué)提到了BFC這個(gè)詞,作為求知好問(wèn)的好學(xué)生墩划,哪里不懂查哪里涕刚,那么今天就來(lái)研究一...
    這名字真不對(duì)閱讀 6,548評(píng)論 3 19
  • 問(wèn)答題47 /72 常見(jiàn)瀏覽器兼容性問(wèn)題與解決方案? 參考答案 (1)瀏覽器兼容問(wèn)題一:不同瀏覽器的標(biāo)簽?zāi)J(rèn)的外補(bǔ)...
    _Yfling閱讀 13,734評(píng)論 1 92
  • Visual formatting model 參考 Visual formatting model CSS b...
    吳立寧閱讀 1,222評(píng)論 0 2
  • 什么是BFC BFC全稱是Block Formatting Context乙帮,即塊格式化上下文。它是CSS2.1規(guī)范...
    clfeng閱讀 454評(píng)論 0 0
  • 什么是BFC BFC全稱是Block Formatting Context极景,即塊格式化上下文察净。它是CSS2.1規(guī)范...
    陌客百里閱讀 531評(píng)論 3 4