06-XX-flexbox-navbar-width.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. width: 25%;
  26. -moz-box-sizing: border-box;
  27. box-sizing: border-box;
  28. background-color: #12459e;
  29. outline: 1px solid #fff;
  30. }
  31. .navbar li a {
  32. display: block;
  33. text-decoration: none;
  34. line-height: 1.75em;
  35. padding: 1em;
  36. color: #fff;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <nav class="navbar">
  42. <ul>
  43. <li><a href="/home">Home</a></li>
  44. <li><a href="/spaceships">Spaceships</a></li>
  45. <li><a href="/planets">Planets</a></li>
  46. <li><a href="/stars">Stars</a></li>
  47. </ul>
  48. </nav>
  49. </body>
  50. </html>