练习10_伪类.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. .content ul li:hover{
  9. background-color: #307df7;
  10. cursor: pointer;
  11. }
  12. .header{
  13. text-align: center;
  14. border-bottom: 1px solid blue;
  15. }
  16. .content{
  17. width: 400px;
  18. margin: 0 auto;
  19. /* background-color: red; */
  20. }
  21. .content li{
  22. width: 300px;
  23. background-color: #aaa;
  24. list-style: none;
  25. margin-top: 20px;
  26. /* height: 50px;
  27. line-height: 50px;
  28. padding-left: 20px; */
  29. padding: 20px;
  30. border-radius: 10px;
  31. color: white;
  32. }
  33. .content li:nth-child(even){
  34. background-color: #666;
  35. }
  36. .content li:first-child{
  37. background-color: #307df7;
  38. }
  39. .content li:last-child:hover::after{
  40. content: "这是最后一个列表";
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="container">
  46. <div class="header">
  47. <h1>我的简单网页</h1>
  48. </div>
  49. <div class="content">
  50. <p>以下是一些列表项:</p>
  51. <ul>
  52. <li>项目一</li>
  53. <li>项目二</li>
  54. <li>项目三</li>
  55. <li>项目四</li>
  56. <li>项目五</li>
  57. </ul>
  58. </div>
  59. </div>
  60. </body>
  61. </html>