image.png

制作思想

  • nav-items 盒子 用 display:flex,盒子里面包 a

index.html

  1. <!-- 主导航栏 -->
  2. <nav>
  3. <div class="nav-common">
  4. <div class="nav-items">
  5. <a href="">酒店</a>
  6. </div>
  7. <div class="nav-items">
  8. <a href="#">特价酒店</a>
  9. <a href="#">特价酒店</a>
  10. </div>
  11. <div class="nav-items">
  12. <a href="#">特价酒店</a>
  13. <a href="#">特价酒店</a>
  14. </div>
  15. </div>
  16. <div class="nav-common">
  17. <div class="nav-items">
  18. <a href="">酒店</a>
  19. </div>
  20. <div class="nav-items">
  21. <a href="#">特价酒店</a>
  22. <a href="#">特价酒店</a>
  23. </div>
  24. <div class="nav-items">
  25. <a href="#">特价酒店</a>
  26. <a href="#">特价酒店</a>
  27. </div>
  28. </div>
  29. <div class="nav-common">
  30. <div class="nav-items">
  31. <a href="">酒店</a>
  32. </div>
  33. <div class="nav-items">
  34. <a href="#">特价酒店</a>
  35. <a href="#">特价酒店</a>
  36. </div>
  37. <div class="nav-items">
  38. <a href="#">特价酒店</a>
  39. <a href="#">特价酒店</a>
  40. </div>
  41. </div>
  42. </nav>

index.css

/* 主导航栏 */
nav {
  border-radius: 10px;
  margin: 3px 5px 3px;
}

nav .nav-common {
  display: flex;
  height: 88px;
  background-color: pink;
}


nav .nav-common:nth-child(2) {
  margin: 3px 0;
}

nav .nav-common .nav-items {
  flex: 1px;
  display: flex;
  flex-direction: column;

}

nav .nav-common .nav-items:nth-child(-n+2) {
  border-right: 1px solid #fff;
}

nav .nav-common .nav-items a {
  flex: 1;
  line-height: 44px;
  text-align: center;
  color: #fff;
  text-shadow: 1px 1px rgba(0, 0, 0, .2);
}


nav .nav-common .nav-items a:nth-child(1) {
  border-bottom: 1px solid #fff;
}


nav .nav-common .nav-items:nth-child(1) a {
  border-bottom: 0;
  background: url(../images/hotel.png) no-repeat bottom center;
  background-size: 121px auto;
}