html - How to let the Navigation Bar (and maybe other stuff) end on the right -
so i've got problem navigation bar. i've set width 100%. see end, because it's got rounded corners...
so this: | (=======) |
not it's now: | (==========|
#nav { height: 60px; font-size: 30px; line-height: 60px; vertical-align: middle; text-align: center; background-color: #0080ff; width: 100%; border: 10px solid #16044e; border-radius: 20px; z-index: 1; } #nav ul {} #nav li { display: inline; text-align: center; margin: 20px; } #nav { color: white; text-decoration: none; }
<ul id="nav"> <li><a href="">home</a> </li> <li><a href="">courses</a> </li> <li><a href="">subjects</a> </li> <li><a href="">sign up</a> </li> <li><a href="">log in</a> </li> </ul>
you can use calc
reduce 10px
total width (10px
= border-width
) should try box-sizing:border-box
browser support calc
limited caniuse
#nav { height: 60px; font-size: 30px; line-height: 60px; vertical-align: middle; text-align: center; background-color: #0080ff; width: calc(100%-10px); border: 10px solid #16044e; border-radius: 20px; z-index: 1; } #nav ul { } #nav li { display: inline; text-align: center; margin: 20px; } #nav { color: white; text-decoration: none; }
<ul id="nav"> <li><a href="">home</a></li> <li><a href="">courses</a></li> <li><a href="">subjects</a></li> <li><a href="">sign up</a></li> <li><a href="">log in</a></li> </ul>
Comments
Post a Comment