伪元素练习.html 1.5 KB

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