[英]No matter what I do, my div doesn't want to be 100% height… :/
Edit: I found out that for some strange reason my #content inherits a height property. 编辑:我发现由于某种奇怪的原因,我的#content继承了height属性。 I don't know why though, or why that is overwriting the height I am trying to set. 我不知道为什么,或者为什么这会覆盖我要设置的高度。 :/ :/
I did a lot of research on that, but I am not that good with css yet, so I can not seem to figure it out. 我对此进行了大量研究,但是对CSS的了解还不够好,因此我似乎无法弄清楚。 I am making a small website for a uni project, and everything works fine, except for one thing. 我正在为uni项目制作一个小型网站,除一件事情外,其他一切都正常。 The content div just does not want to fill out the height that I tell it to. 内容div只是不想填写我告诉它的高度。
<body>
<div id="container">
<div class="logo"><img src="/Users/sophie/Dropbox/3 Uni/MultiEngI/Aufgabe 1/Acc/ArtArchiveLogo500.png" alt="ArtArchive" /></div>
<div class="header">ArtArchive</div>
<div id="nav"><li>
<ul>
<a href="#">Upload</a>
</ul>
<ul>
<a href="#">Organize</a>
</ul>
<ul>
<a href="#">Browse</a>
</ul>
</li>
</li></div>
<div id="content" style="height:100%;">I am empty :(</div>
<div class="footer">I am empty :(</div>
</div>
</body>
that is the html part, and that the css: 这是html部分,而css:
.header {
background:#c61350;
height: 100px;
line-height: 100px;
text-align: center;
padding:10px;
}
.header {
border-bottom: 12px solid #cd365b;
color: white;
font-size: 36px;
font-family: 'Lato',arial,sans-serif;
letter-spacing: 50px;
}
#content {
height : auto !important;
height : 100%;
min-height : 100%;
background: #fff;
width: 60%;
overflow: auto;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
padding:10px;
padding-bottom:80px; /* Height of the footer element */
}
.footer {
width:100%;
height:80px;
position:absolute;
bottom:0;
left:0;
background:#5f4e54;
}
The div with the id content is supposed to be 100% height and it is not. 具有id内容的div应该是100%的高度,不是。 Thank you for reading this :) 谢谢您阅读此篇 :)
You're declaring height : auto !important;
您在声明height : auto !important;
. 。 The !important
declaration takes precedence over other identical style properties. !important
声明优先于其他相同的样式属性。 Simply remove this: 只需删除此:
#content {
height: auto;
height: 100%;
min-height : 100%;
...
}
Do note though that your #content
element will be 100% the height of its #container
parent. 请注意,虽然#content
元素的高度是其#container
父对象的高度的100%。 If your #container
element has no height itself, your #content
element will also have no height. 如果您的#container
元素本身没有高度,则您的#content
元素也将没有高度。 You may want to use the vh
unit instead. 您可能要改用vh
单位。 If this is the case, please see my other answer here: Make div 100% height of browser window . 如果是这种情况,请在此处查看我的其他答案: 将div设置为浏览器窗口高度的100% 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.