隐藏固定位置元素的溢出 [英] Hide overflow on elements with fixed position

查看:34
本文介绍了隐藏固定位置元素的溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法用容器隐藏固定 div的溢出?我认为fixed inside fixed 可以做到,但似乎并非如此.我能想到的唯一解决方法是倒置"蒙版:其他固定 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 .

这篇关于隐藏固定位置元素的溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆