html - Navbar item moves down when resizing -


i'm creating first responsive website. have navbar inside container centered horizontally. has size percentage (is there term this?). navbar scales down when resize window correctly. last list item (navbar item) move down.

i have tried lot min-width stuff, , know has this. solutions on internet should give navbar (or ul?) fixed width (xxxx px). don't want because want scale.

html:

<body> <div id="container"> <nav>     <ul>         <li><span class="navbaritem">test1</span></li>         <li><span class="navbaritem">test2</span></li>         <li><span class="navbaritem">test3</span></li>         <li><span class="navbaritem">test4</span></li>         <li><span class="navbaritem">test5</span></li>     </ul> </nav> </div> </body> 

css:

    @charset "utf-8"; /* css document */  html {         width:100%;     height:100%; } body {     background-image:url(images/background.png);     background-repeat:repeat;     min-height:100%;     margin:0px;     overflow: auto; } #container {     height:100%;     width:73.20%;     background-color:#00cc00;     margin: auto;     left:0; right:0;     top:0; bottom:0;     position:absolute; } #navbar {     min-width:100%;     min-height:13.28125%;     position:absolute;     background-color:#ff0000; } nav {     position:relative;     background-color:#ff0000;     color: #888;     display: block;     width:100%;     height:13.28125%; } nav ul {     list-style-type:none;     width:100%;     height:100%;     margin:0;     padding:0; } nav li {     display: table;     float:left;     border-style: solid;     border-width: 1px;     border-color:#333;     width:20%;     height:100%;     text-align:center;     box-sizing:border-box; } .navbaritem {     font-family: cambria;     color:#cccccc;     font-size:36px;     display: table-cell;     vertical-align: middle; } 

you can change width of menu item 20% , apply box-sizing:border-box. problem due insufficient width @ smaller screen sizes when mixing border size in px , width in %.

see fiddle


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -