简体   繁体   English

显示低于100%高度绝对div的内容

[英]display content below 100% height absolute div

There are lots of questions around this subject but non i've found that seem to work for me. 关于这个问题有很多问题,但我发现这似乎对我没有帮助。 I have a header element that i set to position:absolute; height:100% 我有一个标头元素,我将其设置为position:absolute; height:100% position:absolute; height:100% , however the content under this goes behind the absolute element. position:absolute; height:100% ,但是在此之下的内容在绝对元素之后。 What's the best way to solve this issue? 解决此问题的最佳方法是什么? here's simplified version of my code: 这是我的代码的简化版本:

html: HTML:

<div class="container">
    <header></header>
    <div class="content"></div>
</div>

css: CSS:

header {
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: 1;
    float: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

things i've tried: making the container relative: 我尝试过的事情:使容器相对:

/** this still covers the div below and appears to make no difference **/
.container { 
    height: 100%;
    width: 100%
    position: relative;
}

adding margin to the content: 为内容增加边距:

/**works for one screen-size but not responsive obviously **/
.content {
    margin-top: 200px;
}

adding a 'filler' div html: 添加一个'filler'div html:

<div class="container">
    <header></header>
    <!-- also tried putting the spacer into the header with no results -->
    <div class="spacer"></div>
    <div class="content"></div>
</div>

css: CSS:

.spacer {
    height:100%;
    /* also tried min-height: 100%;
}

any suggestions where i am going wrong, and what i should try? 任何建议,我要去哪里错了,我应该尝试什么?

Remove the position and overflow rules from your CSS. 从CSS中删除positionoverflow规则。


I recommend you use the firebug plugin in Firefox. 我建议您在Firefox中使用firebug插件。 Go to internet and find the plugin and install it. 转到互联网,找到插件并安装。 It's more effective with Firefox more than Chrome or any other browsers. 使用Firefox比使用Chrome或其他任何浏览器更有效。

After that where ever something went wrong. 之后,哪里出了问题。 Just right click on that and click "inspect with firebug". 只需右键单击它,然后单击“检查萤火虫”。 Then you can inspect or add new attributes and see the impact of each change. 然后,您可以检查或添加新属性,并查看每个更改的影响。

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

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