html - Fixed navbar content to the right -


i'm working on project run through small issue can't find solution for.

so idea is: have nav bar fixed. need scroll inside , when click on button content in middle goes right small part outside navbar.

at first thought add

  overflow-y: auto; 

to navbar apprently doesn't work , clips content.

i have created codepen show problem.

http://codepen.io/denniswegereef/pen/vjqbxa

looks it's because you're trying set height match window, have padding. can use box-sizing:border-box make padding included in specified height.

var $item = $('.item'),    $button = $('.button');    (i = 0; < 200; i++) {    $item.append(i + '<br>')  }    $button.on("click", function() {    $item.toggleclass('addmargin');  });
.sidenav {    width: 300px;    background-color: grey;    position: fixed;    padding: 20px;    height: 100vh;    overflow-y: auto;    box-sizing: border-box;  }  .addmargin {    margin-left: 60px;  }  .item {    transition: margin-left 1s cubic-bezier(0.36, -0.48, 0, 2.22);    width: 100%;    background-color: orange;  }  body {    box-sizing: border-box;    margin: 0;    padding: 0;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>  <div class="sidenav">    <button class="button">test</button>    <div class="item">    </div </div>


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -