4.垂直导航.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .list{
  9. /* 清除ul的默认样式 */
  10. list-style: none;
  11. }
  12. /* 包含选择器 */
  13. .list li {
  14. width: 450px;
  15. height: 80px;
  16. background: #0f0;
  17. /* 文字在已知宽高的盒子内
  18. 垂直居中的line-height就是当前高度
  19. */
  20. /* 文本位置 */
  21. text-align: center;
  22. /* 行间距 */
  23. line-height: 80px;
  24. }
  25. a {
  26. /* 清除a标签默认样式 */
  27. text-decoration: none;
  28. /* text-decoration: underline; */
  29. /* 添加划线
  30. underline 下划线
  31. overline 上划线
  32. line-through 删除线
  33. none 无样式
  34. */
  35. }
  36. /* 划过 */
  37. /* 伪类选择器 */
  38. /* :hover 划过*/
  39. /* .list li:hover{
  40. background: #ff0;
  41. }
  42. .list li a:hover {
  43. color: red;
  44. } */
  45. .list li:nth-child(3) a {
  46. color: red;
  47. }
  48. .list li:last-child a {
  49. color: #000;
  50. }
  51. /*
  52. :nth-child()自定义子类
  53. 奇数 2n+1 odd
  54. 偶数 even 2n
  55. :first-child 第一个
  56. :last-child 最后一个
  57. */
  58. </style>
  59. </head>
  60. <body>
  61. <!--
  62. 类选择器:
  63. 在body标签中
  64. 开始标签上 class="xxx"
  65. 在style上
  66. .xxx {代码}
  67. -->
  68. <ul class="list">
  69. <li><a href="">首页</a></li>
  70. <li><a href="" >我的</a></li>
  71. <li><a href="">购物车</a></li>
  72. <li><a href="">订单</a></li>
  73. <li><a href="">浏览记录</a></li>
  74. </ul>
  75. </body>
  76. </html>