简体   繁体   English

不管我做什么,我的div都不想成为100%的身高…:/

[英]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.

相关问题 高度为100%并显示的div:网格未达到我的期望 - div with 100% height and display: grid doesn't do what I expect 如果我使用 HTML5 文档类型,为什么我不能使我的 div 高度为 100%? 我如何得到它 100% 的高度 - Why can't I make my div 100% height if I use an HTML5 doctype? How do I get it 100% height 我想在 >546px screen(sm) 中以这种格式 col-sm-6 显示我的进度条,但无论我做什么它都没有显示任何变化 - I want to show my progress bar in this format col-sm-6 in >546px screen(sm) but its doesn't show any changes no matter what i do 无论我做什么,可调整大小的div都无法正常工作 - Resizable div just isn't working no matter what I do 无论如何,section 都不会变成 100% 浏览器高度 - No matter what, section won't become 100% browser height div不占整个高度/不是100% - div doesn't take the whole height / is not 100% 在这里,我想要在我的底部100%高度,我不想超过我在“.main”类中修复400px高度 - Here I want 100% height in my bottom section and I don't want exceed what I fixed 400px height in “.main” class 突破后div的最后部分不想占用屏幕高度的100% - The last part of div after break-after doesn't want to take 100% of screen height 滚动DIV,我想在其中添加100%高度的DIV - Scrolling DIV, I want a DIV inside of it with 100% Height 我做什么都不会改变 - Div is not changing position no matter what I do
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM