06-24-flexbox-navbar-nowidth.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Navbar using flexbox, no width</title>
  6. <script src="js/html5shiv.min.js"></script>
  7. <style>
  8. nav {
  9. display: block;
  10. }
  11. .navbar ul {
  12. display: -webkit-flex;
  13. display: -ms-flexbox;
  14. display: -webkit-box;
  15. display: -moz-box;
  16. display: flex;
  17. font-family: 'Avenir Next', Avenir, Corbel, 'Franklin Gothic', 'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
  18. list-style: none;
  19. padding: 0;
  20. background-color: #486a8e;
  21. }
  22. .navbar li {
  23. text-transform: uppercase;
  24. text-align: center;
  25. -moz-box-sizing: border-box;
  26. box-sizing: border-box;
  27. background-color: #12459e;
  28. outline: 1px solid #fff;
  29. }
  30. .navbar li a {
  31. display: block;
  32. text-decoration: none;
  33. line-height: 1.75em;
  34. padding: 1em;
  35. color: #fff;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <nav class="navbar">
  41. <ul>
  42. <li><a href="/home">Home</a></li>
  43. <li><a href="/spaceships">Spaceships</a></li>
  44. <li><a href="/planets">Planets</a></li>
  45. <li><a href="/stars">Stars</a></li>
  46. </ul>
  47. </nav>
  48. </body>
  49. </html>