简体   繁体   中英

Twitter Bootstrap sidebar extended to bottom

I am using twitter bootstrap, after reading all the answers on stack overflow to extend a div to the bottom i came up with this code for my sidebar.

body

<div id="wrapper-sidebar">
    <div id="content-sidebar" class="text-center">
        <h1> hello</h1>
        <p>welcome to the admin panel</p>
        <p>have a nice stay!</p>
    </div>
</div>

css

#wrapper-sidebar 
{
    margin: 0 auto;
    width: 300px;
    height: 100%;
    padding: 0;
    position: absolute;
}
#content-sidebar 
{
    background-color: #f5f5f5;
    border: 1px solid #e3e3e3;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
     border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
    -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
     box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
     height: 100%;
     padding-top: 5px;
}
.text-center 
{
  text-align: center;
}

Now this did make the sidebar extend till the bottom of my page but it also inserted a scroll-bar, and when i scroll down my text gets cut off. Any help would be appreciated. Does anyone know how to extend a div/sidebar (ie, height=100%) using bootstrap css classes only?

jfiddle is here but it actually doesn't show the text being cut off thus i did not post it before.

I believe the scrollbar is being introduced by the padding-top and/or the border . You may need to reduce your height to account for these.

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