如何将一个固定的div放在另一个固定的div下? [英] How to position a fixed div under another fixed div?
问题描述
我正在尝试在另一个固定div(标题)的正下方直接设置一个固定div div(菜单),并且定位也应在不同的屏幕尺寸下工作。
我通过带有切换的JQuery调用菜单 div,它出现在标题 div下。我可以将顶部固定值设置为大于标题 div的高度,但是如果我不希望标题具有固定的PX值,该怎么做?
有什么建议吗?
I am trying to set a fixed div div(menu) directly under another fixed div (header) and the positioning should also work with different screen sizes. I call the "menu" div through JQuery with toggle and it appears under the "header" div. I can do this setting a fixed top value greater than the height of the "header" div but if I do not want the header to have a fixed PX value how do I do this? Any suggestions?
html:
<div id="header">
<div id="menu">
</div>
</div>
css:
#header{
position:fixed
height:15%;
width:100%;
background-color:blue;
}
#dropdown{
display:none;
position:fixed;
top:?
}
推荐答案
有一个固定的包装器,而其他2个div通常按照传统方式流动。
Have a wrapper that is fixed, and just have the other 2 divs flow traditionally.
#header-container {
position:fixed
height:15%;
width:100%;
background-color:blue;
}
#header, #dropdown {
width:100%;
}
<div id="header-container">
<div id="header">
</div>
<div id="dropdown">
</div>
</div>
这篇关于如何将一个固定的div放在另一个固定的div下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!