06-31-flexbox-navbar-align-stretch.html 1.4 KB

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