css – body标签溢出(自动,可见?)

前端之家收集整理的这篇文章主要介绍了css – body标签溢出(自动,可见?)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
为什么body元素不使用overflow-y:auto但它的行为方式仍然相同?

我相信它默认是可见的,但它实际上是如何工作的?

解决方法

body(和html)标记是特殊情况,位于DOM层次结构的根目录下,浏览器必须将它们呈现为设置为auto.

这在CSS 2.1中的overflow documentation on W3中有所概述:

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

原文链接:https://www.f2er.com/css/242413.html

猜你在找的CSS相关文章