06-33-flexbox-navbar-align-center.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: center</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. -webkit-align-items: center;
  18. -ms-flex-align: center;
  19. -webkit-box-align: center;
  20. -moz-box-align: center;
  21. align-items: center;
  22. min-height: 100px;
  23. font-family: 'Avenir Next', Avenir, Corbel, 'Franklin Gothic', 'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
  24. list-style: none;
  25. padding: 0;
  26. background-color: #486a8e;
  27. }
  28. .navbar li {
  29. text-transform: uppercase;
  30. text-align: center;
  31. -moz-box-sizing: border-box;
  32. box-sizing: border-box;
  33. background-color: #12459e;
  34. outline: 1px solid #fff;
  35. }
  36. .navbar li a {
  37. display: block;
  38. text-decoration: none;
  39. line-height: 1.75em;
  40. padding: 1em;
  41. color: #fff;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <nav class="navbar">
  47. <ul>
  48. <li><a href="/home">Home</a></li>
  49. <li><a href="/spaceships">Spaceships</a></li>
  50. <li><a href="/planets">Planets</a></li>
  51. <li><a href="/stars">Stars</a></li>
  52. </ul>
  53. </nav>
  54. </body>
  55. </html>