简体   繁体   English

直接将DIV定位在宽度为100%的自动高度固定位置DIV下

[英]Positioning a DIV directly under 100% width auto-height fixed-position DIV

So, first post here, and I have been going nuts trying to figure out the answer to this problem. 因此,在这里的第一篇文章,我一直很努力地试图找出这个问题的答案。

I have two divs: 我有两个股利:

#splash {
width:100%;
min-width:1024px;
height:auto;
position:fixed;
top:80px;
z-index:-1;
}

#maincontentwrap {
width:100%;
min-width:1024px;
height:2000px;
z-index:100;
background:#838d82;
}

The idea I am trying to express is that I want #maincontentwrap to be positioned directly under #splash, but I want #maincontentwrap to remain fixed in position while #splash scrolls over it. 我要表达的想法是,我希望#maincontentwrap定位在#splash的正下方,但是我希望#maincontentwrap在#splash滚动时保持固定位置。 I guess the problem lay in the fact that I'm trying to position something directly under another that has a varying height. 我猜问题出在我试图将某个物体直接放置在另一个高度可变的物体下面的事实。

Any insight into this matter would be greatly appreciated. 任何对此事的见识将不胜感激。 Two days of tinkering has not turned up much. 两天的修补工作并没有太多。

Thanks in advance!! 提前致谢!!

You should use position: fixed or position: absolute in your #maincontentwrap and adjust the margins and paddings accordling to the height of #splash . 您应该在#maincontentwrap使用position: fixedposition: absolute ,并根据#splash的高度调整边距和内#splash

If the height is determined at runtime, you should consider using JavaScript to calculate and set the margins for #maincontentwrap . 如果高度是在运行时确定的,则应考虑使用JavaScript计算和设置#maincontentwrap的边距。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM