国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

javascript - 關于使用overflow: hidden來清除浮動的疑問

瀏覽:91日期:2022-12-21 13:48:30

問題描述

正常情況下,給浮動的父元素設置overflow:hidden;就可以清楚浮動,但是我發現被浮動元素的父元素是body時,給body設置overflow:hidden,是無法清除浮動的,有人說是body不屬于普通流,所以無效,有誰能解釋下嗎?

感謝:CRIMX借用王大陸的一句話:

你這種人不是大神,就是走在成為大神的路上。

問題解答

回答1:

這是因為并沒有產生新的 BFC

產生新 BFC 的一個條件:

Block-level, non-replaced elements in normal flow when ’overflow’ does not compute to ’visible’ (except if the ’overflow’ property’s value has been propagated to the viewport).

為什么對 <body> 設置 overflow 會擴散到 viewport:

UAs must apply the ’overflow’ property set on the root element to the viewport. When the root element is an HTML 'HTML' element or an XHTML 'html' element, and that element has an HTML 'BODY' element or an XHTML 'body' element as a child, user agents must instead apply the ’overflow’ property from the first such child element to the viewport, if the value on the root element is ’visible’. The ’visible’ value when used for the viewport must be interpreted as ’auto’. The element from which the value is propagated must have a used value for ’overflow’ of ’visible’.

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 古浪县| 福清市| 贵阳市| 汝州市| 新兴县| 曲阳县| 原阳县| 云霄县| 吉安市| 陇西县| 钟山县| 稷山县| 镇平县| 济南市| 来凤县| 永丰县| 长沙市| 堆龙德庆县| 禹城市| 如东县| 电白县| 古交市| 齐齐哈尔市| 镇远县| 台中县| 板桥市| 西乌珠穆沁旗| 神木县| 永兴县| 吉水县| 桓仁| 清新县| 和硕县| 双桥区| 崇义县| 扶绥县| 新蔡县| 永嘉县| 万载县| 博兴县| 临汾市|