问题描述
有没有办法用容器隐藏固定 div的溢出?我认为固定内部固定会做到这一点,但事实并非如此.我能想到的唯一解决方法是倒置"掩码:其他固定div隐藏所有围绕着 的东西,但是如果有其他解决方案,那就更好了.
Is there any way to hide the overflow of a fixed div with a container? I thought fixed inside fixed would do it, but it seems it's not the case. The only workaround I can think of is "inverted" masks: other fixed divs hiding everything around the one, but it'd be better if there are any other solutions.
这是小提琴: http://jsfiddle.net/pjFa6/1/
推荐答案
不幸的是,似乎不可能将固定元素嵌套在另一个元素中(无论是否固定),并希望外部元素将其包装并隐藏任何溢出.
Unfortunately it seems to be impossible to nest a fixed element within another element (fixed or not) and expect the outer element to wrap it and hide any overflow.
我唯一想到的就是将内部div设置为position:absolute
而不是固定的.这是一个基于您的jsfiddle的示例: jsfiddle.net/pjFa6/15 .
The only thing I can think of is setting the inner div to position:absolute
instead of fixed. Here is an example based on your jsfiddle: jsfiddle.net/pjFa6/15 .
这篇关于隐藏具有固定位置的元素上的溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!