04.网易新闻的右侧列表.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>网易新闻的右侧列表</title>
  8. <link rel="stylesheet" href="css/reset.css">
  9. <style>
  10. /* 去除下划线 */
  11. a {
  12. text-decoration: none;
  13. }
  14. /* 设置容器的样式 */
  15. .news-wrapper {
  16. /* 设置宽度 */
  17. width: 300px;
  18. /* 设置高度 */
  19. height: 400px;
  20. /* 设置居中 */
  21. margin: 50px auto;
  22. /* 设置背景颜色 */
  23. background-color: #bfa;
  24. /* 设置上边框 */
  25. border-top: 1px solid #ddd;
  26. }
  27. /* 设置news-title */
  28. .news-title {
  29. /* 为了边框和文字宽度一致,需要将h2转换为行内块元素 */
  30. display: inline-block;
  31. /* 设置高度 */
  32. height: 20px;
  33. /* 设置上边框 */
  34. border-top: 1px red solid;
  35. /* 通过margin-top将h2上移,盖住上边框 */
  36. margin-top: -1px;
  37. padding: 10px;
  38. }
  39. /* 设置title中超链接的样式 */
  40. .news-title a {
  41. /* 设置颜色 */
  42. color: #40406b;
  43. /* 设置文字的加粗效果 */
  44. font-weight: bold;
  45. }
  46. /* 设置图片容器的高度 */
  47. .news-img {
  48. height: 200px;
  49. }
  50. /* 设置图片样式 */
  51. .news-wrapper .news-img img {
  52. width: 100%;
  53. }
  54. /* 设置图片的文字效果 */
  55. .news-img .img-title {
  56. /* 向上移动文字 */
  57. margin-top: -30px;
  58. /* 设置文字颜色 */
  59. color: blue;
  60. /* 设置加粗 */
  61. font-weight: bold;
  62. /* 设置内边距 */
  63. padding-left: 30px;
  64. }
  65. /* 设置新闻列表 */
  66. .news-list {
  67. /* 设置上外边距 */
  68. margin-top: 30px;
  69. /* 设置左侧的padding */
  70. /* padding-left: 14px; */
  71. /* 设置项目符号 */
  72. /* list-style: square; */
  73. }
  74. /* 设置li */
  75. .news-list li {
  76. /* 设置下外边距 */
  77. margin-bottom: 17px;
  78. }
  79. /* 设置li中的文字 */
  80. .news-list li a {
  81. /* 设置字体大小 */
  82. font-size: 14px;
  83. /* 设置字体颜色 */
  84. color: #666;
  85. }
  86. /* 通过before伪元素,来为每一个li添加项目符号 */
  87. .news-list li::before {
  88. content: '■';
  89. /* color: rgb(218,218,218); */
  90. color: #666;
  91. margin-right: 10px;
  92. }
  93. /* 设置超链接鼠标移入的样式 */
  94. .news-list li a:hover {
  95. color: red;
  96. }
  97. </style>
  98. </head>
  99. <body>
  100. <!-- 创建新闻列表的外层容器 -->
  101. <div class="news-wrapper">
  102. <!-- 创建一个标题标签 -->
  103. <h2 class="news-title">
  104. <a href="#">体育</a>
  105. </h2>
  106. <!-- 创建一个图片的容器 -->
  107. <div class="news-img">
  108. <a href="#">
  109. <img src="images/mtc.jpg" alt="摩托车">
  110. <!-- 创建图片标题 -->
  111. <h3 class="img-title">
  112. 新款摩托,泡妞神器
  113. </h3>
  114. </a>
  115. </div>
  116. <!-- 新闻列表 -->
  117. <ul class="news-list">
  118. <li>
  119. <a href="#">最美门将变短视频女神 四年后回归国家队</a>
  120. </li>
  121. <li>
  122. <a href="#">只剩足球的许老板还能逆袭吗?</a>
  123. </li>
  124. <li>
  125. <a href="#">科尔G1完爆基德:“我预判了你的预判!”</a>
  126. </li>
  127. <li>
  128. <a href="#">印度名宿:我们已是羽毛球超级大国</a>
  129. </li>
  130. </ul>
  131. </div>
  132. </body>
  133. </html>