结论:当父元素 height:auto 时,子元素的 height:100% 等价于 height:auto,无法产生限制效果。
场景说明
- 页面根容器 500px 且
overflow:hidden;祖父元素height:auto;父元素height:100%且overflow-y:auto;子元素高度 1000px:- 实际不会出现滚动条,因为父
height:100%被解释为auto→ 父高度随内容扩张,不产生溢出。
- 实际不会出现滚动条,因为父
结论:当父元素 height:auto 时,子元素的 height:100% 等价于 height:auto,无法产生限制效果。
overflow:hidden;祖父元素 height:auto;父元素 height:100% 且 overflow-y:auto;子元素高度 1000px:
height:100% 被解释为 auto → 父高度随内容扩张,不产生溢出。