简体   繁体   中英

Collapsing sidebar bootstrap

I'm new to Bootstrap and have a little problem with understanding how does the grid system works. Initially, I have the following code for a page with a sidebar:

    <div class="row"> 
  <div class="sidebar col-xs-3">
         <div class="well">   
         <ul class="sidebar-nav">
                <li class="sidebar-brand">
                    <a href="#">
                        Navigation
                    </a>
                </li>
                <li>
                    <a href="#">Item 1</a>
                </li>
                <li>
                    <a href="#">Item 2</a>
                </li>
                <li>
                    <a href="#">Item 3</a>
                </li>
                <li>
                    <a href="#">Item 4</a>
                </li>
                <li>
                    <a href="#">Item 5</a>
                </li>
                <li>
                    <a href="#">Item 6</a>
                </li>
                <li>
                    <a href="#">Item 7</a>
                </li>
            </ul>

         </div>
   </div>
    <div class= "main col-xs-9">
         <div class="well">body</div>   
    </div> 

  </div>

With the following css:

/* Sidebar Styles */
.sidebar-nav {
    top: 0;
    width: 250px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: #999999;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #000;
    background: rgba(255,255,255,0.2);
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    height: 65px;
    font-size: 18px;
    line-height: 60px;
}

.sidebar-nav > .sidebar-brand a {
    color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
    color: #000;
    background: none;
}

It works fine on big screens while having the following problem on small screen size: 在此处输入图片说明

I would highly appreciate any explanation about why the sidebar text is not resizing right to the sidebar area? Thanks for any help.

The problem was resolved by using different classes for sidebar and body

<div class="sidebar col-md-3 col-xs-6">

</div>
<div class= "main col-md-9 col-xs-6">
     <div class="well">body</div>   
</div> 

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