全高导航条奇怪错误

时间:2016-06-17 02:16:35

标签: html css navigation height

好吧所以我把ul高度100%和li一块到了阻挡等级但由于某种原因我不能让我的垂直导航达到全高。好吧,我真的想让它停在页脚的右边。所以这里是代码:我在ul上添加了背景色,但由于某种原因它没有出现在底部

html {
    height: 100%;
}  

body{
    height: 100%;
    margin: 0;
    font-family: courier;
    font-size: 19px;
}

* {
    margin: 0;
}

#pagewrap {
    min-height: 100%;
    margin-bottom: -174px; 
}

#pagewrap:after {
    content: "";
    display: block;
}

#footer, #pagewrap:after {
    height: 174px;
}

.sub:last-child {
    border: 0px;
}

#footer {
    background-color:  #00e600;
}

.wrap {
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
}

.sub {
    padding: 12px;
    width: 32%;
    height: 150px;
    background: #00e600;
    color: white;
    border-right: solid white 1px;  
}


.sub:last-child {
    border: 0px;
}

#nav {
    list-style: none;
    font-weight: bold;
    margin-bottom: 10px;
    width: 10%;
    text-align: center;
    background-color: brown;
    padding-right: 20px;  
}

#nav ul {
    list-style-type: none;
    height: 100%;
    margin: 0px;
    padding: 0;
    overflow: auto;
    background-color: brown;
}

#nav li {
    margin: 0px; 
}

#nav li a {
    padding: 10px;
    display: block;
    text-decoration: none;
    font-weight: bold;
    color: pink;
    background-color: brown;  
}

#nav li a:hover {
    color:  white;
    text-shadow: 2px 2px 4px white;
}

<body>  
    <div id="pagewrap">
        <div id="nav">
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">Works</a></li>
                <li><a href="#">About</a></li>
            </ul>
        </div>
    </div>

<!--
<footer id="footer">

</footer>

-->


<div id="footer">
    <div class="wrap">
        <div class="sub">Lorem Ipsum</div>
        <div class="sub">Lorem Ipsum </div>
        <div class="sub">Lorem Ipsum </div>
    </div>
</div>
</body>

是否有人能够发现问题?

1 个答案:

答案 0 :(得分:2)

要完全满足您的要求(在页脚之前停止垂直导航,您需要组合几种不同的样式。您的原始问题很可能是{{1}之间存在父元素需要增加100%的高度。幸运的是,现在有一种更有效的方法。将以下内容添加到html, body样式中:

#nav

这将使#nav { height: 100vh; } 视口高度达到100%。要容纳页脚,请更新以下代码:

nav

这会计算整个屏幕高度与页脚高度之间的差异,目前为174px。这是一个更新的小提琴:https://jsfiddle.net/44655gw4/1/

相关问题