css - How to center a layout with a fixed sidebar? -


i need centered layout vertical fixed menu on left side of container, using bootstrap 3. on small screens menu inserted left side. have solution sidebar, snippet somewhere. works fine layout not centered (menu , content should centered in typically bootstrap container). if use container div wrapper whole thing, menu no longer fixed.

html:

<div class="navbar navbar-fixed-top visible-xs">     <div class="navbar-header">         <button type="button" class="navbar-toggle"></button>     </div> </div> <div class="row-offcanvas row-offcanvas-left">     <div id="sidebar" class="sidebar-offcanvas col-sm-4">         <div class="col-md-12">             <ul class="nav">                 <li><a href="#">link</a></li>             </ul>         </div>     </div>     <main class="col-sm-8">long long text</main> </div> 

css:

#sidebar {     width: inherit;     min-width: 250px;     max-width: 250px;     float: left;     position:relative;     overflow-y:auto;     overflow-x:hidden; } @media screen , (max-width: 768px) {     .row-offcanvas {         position: relative;      }      .row-offcanvas-left {         left: -250px;      }      .row-offcanvas-left.active {         left: 0;      }      .sidebar-offcanvas {         position: absolute;         top: 0;      } } main {     overflow: auto; } 

i prepared fiddle.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -