亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么清除浮動要設置成width:100%呢?

為什么清除浮動要設置成width:100%呢?

正在回答

3 回答

我的理解:設定了over:hidden;后,浮動的塊不重疊了,而是相鄰的關系,又因為width=100%,所以它需要的寬度是整個一行,所以只能夠靠換行來實現,這相當于清除浮動。

也不知道理解的對不對呢。

0 回復 有任何疑惑可以回復我~
#1

qq_伊藤_03776080 提問者

哦~這樣理解好像有點懂了,謝謝大神
2016-10-26 回復 有任何疑惑可以回復我~

重發一遍。

? 1.<p>設置overflow:hidden觸發BFC。

“Floats, absolutely positioned elements, block containers (such as inline-blocks, table-cells, and table-captions) that are not block boxes, and block boxes with 'overflow' other than 'visible' (except when that value has been propagated to the viewport) establish new block formatting contexts for their contents.

? ?2.p作為block container box,其中的內容與不在一個BFC的float元素是互不影響的。按理說,這樣就已經能夠保證p中inline-level的內容不受float元素的影響了

? The border box of a table, a block-level replaced element, or an element in the normal flow that establishes a new block formatting context (such as an element with 'overflow' other than 'visible') must not overlap the margin box of any floats in the same block formatting context as the element itself. If necessary, implementations should clear the said element by placing it below any preceding floats, but may place it adjacent to such floats if there is sufficient space. They may even make the border box of said element narrower than defined by section?10.3.3.CSS2 does not define when a UA may put said element next to the float or by how much said element may become narrower.?

? 3.最后p加入width:100%(注意,這里100%是相對父元素的寬度的計算值Calculated value)只不過是為了形成“換行”而已

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? --https://www.w3.org/TR/CSS21/visuren.html#img-inline-layout

0 回復 有任何疑惑可以回復我~
#1

qq_伊藤_03776080 提問者

謝謝啦
2016-10-29 回復 有任何疑惑可以回復我~

“Floats, absolutely positioned elements, block containers (such as inline-blocks, table-cells, and table-captions) that are not block boxes, and block boxes with 'overflow' other than 'visible' (except when that value has been propagated to the viewport) establish new block formatting contexts for their contents.”

? ?2.p作為block container box,其中的內容與不在一個BFC的float元素是互不影響的。按理說,這樣就已經能夠保證p中inline-level的內容不受float元素的影響了

The border box of a table, a block-level replaced element, or an element in the normal flow that establishes a new block formatting context (such as an element with 'overflow' other than 'visible') must not overlap the margin box of any floats in the same block formatting context as the element itself. If necessary, implementations should clear the said element by placing it below any preceding floats, but may place it adjacent to such floats if there is sufficient space. They may even make the border box of said element narrower than defined by section?10.3.3.CSS2 does not define when a UA may put said element next to the float or by how much said element may become narrower.?

? 3.最后p加入width:100%(注意,這里100%是相對父元素的寬度的計算值Calculated value)只不過是為了形成“換行”而已

????????????????????????????????????????????????????????????????--https://www.w3.org/TR/CSS21/visuren.html#img-inline-layout

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
網頁布局基礎
  • 參與學習       214678    人
  • 解答問題       1833    個

讓你精通CSS中三大定位機制,徹底掌握網頁布局的相關知識

進入課程

為什么清除浮動要設置成width:100%呢?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號