Nate Anderson Nate Anderson - 3 months ago 9
CSS Question

Fixed div with 100% width in body-content

I am using bootstrap and am trying to fix a div to the top of the

body-container
div.

Using this css, I am able to accomplish fixing the div to the top of the container, but it spills outside the right of the
body-container
div:

.top-bar {
position: fixed;
z-index: 1030;
top: 60px;
width: 100%;
}
.top-bar .item-count h4{
text-align: center;
}


Here is the all my html/css: https://jsfiddle.net/rttvqa3k/

Answer

Check this if its helpful.. :)

OLD:

<div class="top-bar panel panel-default">
    <div class="panel-body row">
        <div class="col-xs-4 col-sm-4 col-md-4">
            <button class="btn btn-default">Button 1</button>
            <button class="btn btn-default">Button 2</button>
        </div>
        <div class="col-xs-4 col-sm-4 col-md-4 matter-count">
            <h4>### Items in Report</h4>
        </div>
        <div class="col-xs-4 col-sm-4 col-md-4">
            <button class="btn btn-default pull-right">Button 3</button>
        </div>
    </div>
</div>

NEW:

<div class="navbar-fixed-top container" style="top:60px;">    
    <div class="panel panel-default">

    <div class="panel-body row">
        <div class="col-xs-4 col-sm-4 col-md-4">
            <button class="btn btn-default">Button 1</button>
            <button class="btn btn-default">Button 2</button>
        </div>
        <div class="col-xs-4 col-sm-4 col-md-4 matter-count">
            <h4>### Items in Report</h4>
        </div>
        <div class="col-xs-4 col-sm-4 col-md-4">
            <button class="btn btn-default pull-right">Button 3</button>
        </div>
    </div>
      </div>
</div>