css 溢出原因:hidden 'On' html '将滚动框移到正文?

vuktfyat  于 2023-01-14  发布在  其他
关注(0)|答案(1)|浏览(130)

我只是偶然发现了overflow: hiddenhtml上的这种用法,这对我来说似乎不合逻辑:

* {
  all: unset;
  display: revert;
}
html {
  height: 100vh;
  overflow: hidden;
  background: black;
}
body {
  height: 50vh;
  font-size: 5rem;
  background: white;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overflow-y: scroll;
}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

这是关于将滚动框从html移动到body,但是我不明白为什么这个例子只适用于overflow: hiddenbody的高度已经只有50vh了,所以html元素不应该发生溢出吗?

jgzswidk

jgzswidk1#

根据质量标准:
但是,当根元素是[HTML] html元素时(包括HTML的XML语法)**其溢出值可见 (在两个轴上),并且该元素具有显示值也不是"无“的主体元素作为子元素,用户代理必须改为将第一个这样的子元素的overflow- 值应用于视口。然后,从中传播值的元素必须具有visible的已用溢出值。
html上设置溢出将禁用传播,并将溢出保留在body元素上

相关问题