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

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - 關(guān)于使用overflow: hidden來清除浮動(dòng)的疑問

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

問題描述

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

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

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

問題解答

回答1:

這是因?yàn)椴]有產(chǎn)生新的 BFC

產(chǎn)生新 BFC 的一個(gè)條件:

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).

為什么對(duì) <body> 設(shè)置 overflow 會(huì)擴(kuò)散到 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’.

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 堆龙德庆县| 宁蒗| 阿尔山市| 正定县| 湟中县| 边坝县| 平阳县| 巴彦淖尔市| 南皮县| 北海市| 建平县| 民和| 奉贤区| 贞丰县| 林甸县| 潍坊市| 祁东县| 天津市| 武川县| 酉阳| 图木舒克市| 上犹县| 凤山市| 红河县| 郓城县| 开鲁县| 松溪县| 太仓市| 濮阳县| 大化| 汉川市| 彝良县| 阳曲县| 广灵县| 凤凰县| 桃江县| 德州市| 丰城市| 慈溪市| 酒泉市| 德昌县|