Horizontal menu does not use 100% of space

Asked

Viewed 88 times

0

Guys I’m making a simple horizontal menu and I split the columns in percentage so the last column isn’t breaking the row. I need the menu this way because it will be responsive.

HTML and CSS

nav ul {
    padding:0px;
    margin:0px;
    list-style:none;
    height: 48px;
    width: 100%;
}

nav ul li {
    display:  inline;
}

nav ul li a {
    /*padding: 2px 22px;*/
    padding: 0;
    width: 11%;
    display: inline-block;
    text-decoration: none;
    color: #664232;
    text-align: center;
    vertical-align: middle;
}

nav ul li a:hover {
    color: #e1dbd8;
    border-top:2px inset #e1dbd8;
    text-decoration: none;
}

.ativo {
    color: #E8CCB0;
    border-top:2px solid #E8CCB0;
    text-decoration: none;
}
<nav style="margin-top: 20px; border-bottom: 1px solid #664232">
    <div class="row">
        <div class="col-sm-12">
            <ul>
                <li  style="line-height: 40px"><a href="#" class="ativo">Apresentação</a></li>
                <li><a href="#">Apresentação<br>Apresentação</a></li>
                <li><a href="#">Apresentação<br>Apresentação</a></li>
                <li style="line-height: 40px"><a href="#">Apresentação</a></li>
                <li><a href="#">Apresentação<br>Apresentação</a></li>
                <li style="line-height: 40px"><a href="#">Apresentação</a></li>
                <li style="line-height: 40px"><a href="#">Apresentação</a></li>
                <li style="line-height: 40px"><a href="#">Apresentação</a></li>
                <li><a href="#">Apresentação<br>Apresentação</a></li>
            </ul>
        </div>
    </div>
</nav>

code in jsfiddle

Thank you

  • You wish for something like this: https://jsfiddle.net/g87bkq11/7/ ?

  • There was an error in css when I posted. width was 10% but the right is 11%. Check it now. I need the menus to stay all in the same space and the last one doesn’t break the line and doesn’t get smaller as was the case when you put 10% in the size.

  • But if you don’t break the line, what must happen?

  • display: flex; is up to advisable

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.