gpt4 book ai didi

css - 滚动时相对 div 越过固定 div

转载 作者:技术小花猫 更新时间:2023-10-29 11:00:11 26 4
gpt4 key购买 nike

我在页面顶部有一个固定位置的 div。 (例如 Facebook)以及页面中相对定位的 div。当我向下滚动时,相对 div 越过固定 div。我希望它在固定的 div 下通过。有什么办法可以解决这个问题吗?

enter image description here

#navcontainer
{
position:fixed;
}

.city
{
position:relative;
float:left;
}

.city .text
{
position:absolute;
top:100px;
left:15px;
}

在这个 css 中,我有一个城市 div,绝对文本位于相对 div (.city) 中的图像上

最佳答案

您好,我认为您应该这样做:

CSS

#navcontainer
{
position:fixed;
background:red;
left:0;
right:0;
top:0;
height:100px;
z-index:3;
}

.city
{
position:relative;
background:green;
left:0;
right:0;
padding:10px;
top:100px;
z-index:2;
}

.city .text
{
padding:10px;
background:yellow;
}​

HTML

<div id="navcontainer">This is navigation</div>

<div class="city">
<div class="text">here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br /></div>
</div>

现场演示 http://jsfiddle.net/xLnKN/1/

关于css - 滚动时相对 div 越过固定 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10303882/

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