简体   繁体   中英

Extra space between menu and the vertical navigation bar

I'm writing website using bootstrap and I got extra space between vertical navigation bar and my site's menu. It's like +/- 10 px on large screen but there is a horizontal bar because of that. My code:

<header>
    <div class="col-sm-8 offset-sm-2">
        <a href="logo"><img src="logo.png" width="100%"/></a>
    </div>
    <nav>
        <ul class="menu col-sm-12">         
            <li><a href="start"><i class="icon-users"></i>  About us</a></li>
            <li><a href="out-products"><i class="icon-leanpub"></i>  Products</a></li>
            <li><a href="contact"><i class="icon-mail-alt"></i>  Contact</a></li>
        </ul>   
    </nav>
</header>

and .menu class in CSS:

.menu
{
    list-style-type: none;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-left: 0px;
    padding-right: 0px;
    margin: 0px;
    font-size: 20px;
    min-height: 30px;
    line-height: 150%;
    letter-spacing: 1px;
    background: linear-gradient(to top, rgba(165,160,160,1), rgba(0,0,0,0));
}

菜单

Anyone knows how to fix this?

You have some errors in your HTML, columns should be in rows like this:

<div class="row">
    <div class="col-8">
        <p> My content </p>
    </div>

    <div class="col-4">
        <p> My other content </p>
    </div>
</div>

Your problem could be fixed if you remove padding-top from .menu or set it to 0

.menu
    {
    list-style-type: none;
    padding-top: 0; // do not add padding to top
    padding-bottom: 8px;
    padding-left: 0px;
    padding-right: 0px;
    margin: 0px;
    font-size: 20px;
    min-height: 30px;
    line-height: 150%;
    letter-spacing: 1px;
    background: linear-gradient(to top, rgba(165,160,160,1), rgba(0,0,0,0));
}

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-2025 STACKOOM.COM