简体   繁体   中英

HTML Navigation Bar extend to bottom

I created a navigation bar for my school project (I'm doing basic design, then we're adding the mysql database), and the bar works great, but it does not extend to the bottom of the page, it's just a little box right now.

Here's my style script

style type='text/css'>
#navigation {
 display:block;
 width:150px;
 float:left;
 margin-left:7px;
 margin-right6px;
 margin:5px;
 border-style:solid;
}
#navhead {
 text-align:center;
 margin-left:7px;
 margin-right:6px;
}
#links {
 display:block;
 width:60px;
}
</style>

Am I missing any attributes that say 'extend to bottom of frame?'

Thanks!

You need to use the height property. You can set the height to 100% (the height of this parent, so the <body> ) but it will looks weird, because it will render the height + the padding + border + margin.
You need to use the border-box property with the height. It allows you to define if the padding and/or border (or none, by default) are count in the height and width properties. You also needs to kill the margin-top and margin-bottom . After those changes, here what your CSS should look like :

#navigation {
    -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;
            box-sizing: border-box;
    display: block;
    width: 150px;
    height: 100%;
    float: left;
    margin-left: 7px;
    margin-right: 5px;
    border-style: solid;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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