简体   繁体   中英

100% width on navigation in a column overflows the page in bootstrap 3

I can't seem to strech my navigation to 100% of the column.
If I use width:100% the navigation streches all over the page.

Do I have to set the width manually for every screen size?
This is for a school and we are forced to use bootstrap 3.

<div class="container">
<div class="row">
    <div id="left" class="col-sm-2 hidden-xs">
        <ul id="navigation" class="nav nav-stacked affix">
            <li><a href="#">Fixed navigation</a></li>
            <li><a href="#">Link</a></li>
        </ul>
    </div>
    <div id="right" class="col-sm-10">
        <h1>Some text</h1>
    </div>
</div>

#right {
background-color: lightblue;
}

#left {  /* For showing the column width */
background-color: orange;
height: 100vh;
}

#navigation{
background-color: lightgreen;
height: 100%;
width: 100%;
}

Here is better look at it. https://www.bootply.com/TKjfHrza8M

Try using fit-content for height and width. Add padding, if needed.

#navigation{
  background-color: lightgreen;
  height: fit-content;
  width: fit-content;
}

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