gpt4 book ai didi

html - 相对于 parent 的 parent 定位固定的 child

转载 作者:太空宇宙 更新时间:2023-11-03 17:28:56 25 4
gpt4 key购买 nike

所以我在浏览器窗口中创建了一个 small_window,在它里面有一个 smaller_window,其中包含一些自动滚动的文本。

而且我还希望 smaller_window 中的一些文本保持静态并且不在 smaller_window 中滚动。所以这里的 pos_fixed 是绝对的,相对于 small_window。

<header>
<style type="text/css">
.small_window{
position:relative;
}

#smaller_window{
height:470px;
overflow-x:hidden;
overflow-y:auto;
position: initial !important; /* I expect this would make pos_fixed a child of small_window instead of smaller_window */
}

p.pos_fixed {
position: absolute;
top: 200px;
right: 30px;
}
</style>
</header>

<body>
<div id="small_window">
<div id="smaller_window">
<p class="pos_fixed">This line is fixed relative to smaller_window</p>
</div>
</div>
</body>

它在 Firefox38 和 IE11 上运行起来就像一个魅力。但是,我怀疑它的跨浏览器兼容性,因为我的移动浏览器(chrome mobile)仍然相对于 smaller_window 定位 pos_fixed,显然已经忽略了

#smaller_window{
position: initial !important;
}

关于相对于 parent 的 parent 定位固定 child 的更好的跨浏览器兼容方式的任何建议?

最佳答案

您没有为 smaller_window 添加类,而是在 css 中为 smaller_window 编写了 id 它如何工作?你可以在 fiddle 中发布你的代码吗??

关于html - 相对于 parent 的 parent 定位固定的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30973987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com