Div带滚动和内容与绝对位置 [英] Div with scroll and content with absolute positions

查看:96
本文介绍了Div带滚动和内容与绝对位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div的样式: overflow-y:scroll; overflow-x:auto;
我试着用绝对或相对位置在这个div内添加图像。一切似乎确定,直到用户尝试滚动div内容:图像保持在固定的位置相对于浏览器窗口。这个问题似乎只有在IE(7),在firefox一切都很好。
有什么解决方案吗?



EDIT(针对下面提出的问题):我定位元素,因为我需要在另一个元素前面显示。

解决方案

我不知道它是一个错误或IE中的功能,但我遇到了同样的事情。幸运的是有一个容易解决。只需在具有可滚动内容的< div> 中添加 position:relative 。 $ b

I have a "div" with style: overflow-y: scroll; overflow-x: auto; I try to dynamicaly add image inside this "div" with absolute or relative position. Everything seems ok until user tries to scroll the "div" content: image stays in fixed position relative to browser window. This problem seems to be only in IE(7), in firefox everything is fine. Is there any solutions for this?

EDIT (in response to questions raised below): I'm positioning the element because I need it to show in front of another element.

解决方案

I don't know if it is a bug or a "feature" in IE, but I've run into the same thing before. Luckily there is an easy fix. Just add "position:relative" to the <div> that has scrollable contents.

这篇关于Div带滚动和内容与绝对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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