练习6_伪类选择器.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. h1{
  9. text-align: center;
  10. /* border:1px solid blue; */
  11. border-bottom: 3px solid blue;
  12. padding-bottom: 20px;
  13. }
  14. /* .line{
  15. height: 1px;
  16. background-color: blue;
  17. } */
  18. .box{
  19. width: 400px;
  20. margin: 0 auto;
  21. }
  22. li{
  23. list-style: none;
  24. height: 70px;
  25. /* background-color: #999; */
  26. margin-bottom: 20px;
  27. padding-left: 20px;
  28. line-height: 70px;
  29. color: #fff;
  30. border-radius: 20px;
  31. }
  32. /* li{
  33. list-style: none;
  34. margin-top: 20px;
  35. padding:20px;
  36. background-color: #999;
  37. } */
  38. /* 偶数项 even 、 2n */
  39. li:nth-child(even){
  40. background-color: #999;
  41. }
  42. /* 奇数项 odd 、 2n-1 */
  43. li:nth-child(odd){
  44. background-color: #333;
  45. }
  46. li:first-child{
  47. background-color: #007bff;
  48. }
  49. li:hover{
  50. background-color: #007bff;
  51. }
  52. li:last-child:hover::after{
  53. content: "最后一个";
  54. }
  55. </style>
  56. </head>
  57. <body>
  58. <h1>我的简单网页</h1>
  59. <!-- <div class="line"></div> -->
  60. <div class="box">
  61. <p>以下是一些列表项:</p>
  62. <ul>
  63. <li>列表项1</li>
  64. <li>列表项2</li>
  65. <li>列表项3</li>
  66. <li>列表项4</li>
  67. <li>列表项5</li>
  68. </ul>
  69. </div>
  70. </body>
  71. </html>