123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>网易新闻的右侧列表</title>
- <link rel="stylesheet" href="css/reset.css">
- <style>
- /* 去除下划线 */
- a {
- text-decoration: none;
- }
- /* 设置容器的样式 */
- .news-wrapper {
- /* 设置宽度 */
- width: 300px;
- /* 设置高度 */
- height: 400px;
- /* 设置居中 */
- margin: 50px auto;
- /* 设置背景颜色 */
- background-color: #bfa;
- /* 设置上边框 */
- border-top: 1px solid #ddd;
- }
- /* 设置news-title */
- .news-title {
- /* 为了边框和文字宽度一致,需要将h2转换为行内块元素 */
- display: inline-block;
- /* 设置高度 */
- height: 20px;
- /* 设置上边框 */
- border-top: 1px red solid;
- /* 通过margin-top将h2上移,盖住上边框 */
- margin-top: -1px;
- padding: 10px;
- }
- /* 设置title中超链接的样式 */
- .news-title a {
- /* 设置颜色 */
- color: #40406b;
- /* 设置文字的加粗效果 */
- font-weight: bold;
- }
- /* 设置图片容器的高度 */
- .news-img {
- height: 200px;
- }
- /* 设置图片样式 */
- .news-wrapper .news-img img {
- width: 100%;
- }
- /* 设置图片的文字效果 */
- .news-img .img-title {
- /* 向上移动文字 */
- margin-top: -30px;
- /* 设置文字颜色 */
- color: blue;
- /* 设置加粗 */
- font-weight: bold;
- /* 设置内边距 */
- padding-left: 30px;
- }
- /* 设置新闻列表 */
- .news-list {
- /* 设置上外边距 */
- margin-top: 30px;
- /* 设置左侧的padding */
- /* padding-left: 14px; */
- /* 设置项目符号 */
- /* list-style: square; */
- }
- /* 设置li */
- .news-list li {
- /* 设置下外边距 */
- margin-bottom: 17px;
- }
- /* 设置li中的文字 */
- .news-list li a {
- /* 设置字体大小 */
- font-size: 14px;
- /* 设置字体颜色 */
- color: #666;
- }
- /* 通过before伪元素,来为每一个li添加项目符号 */
- .news-list li::before {
- content: '■';
- /* color: rgb(218,218,218); */
- color: #666;
- margin-right: 10px;
- }
- /* 设置超链接鼠标移入的样式 */
- .news-list li a:hover {
- color: red;
- }
- </style>
- </head>
- <body>
- <!-- 创建新闻列表的外层容器 -->
- <div class="news-wrapper">
- <!-- 创建一个标题标签 -->
- <h2 class="news-title">
- <a href="#">体育</a>
- </h2>
- <!-- 创建一个图片的容器 -->
- <div class="news-img">
- <a href="#">
- <img src="images/mtc.jpg" alt="摩托车">
- <!-- 创建图片标题 -->
- <h3 class="img-title">
- 新款摩托,泡妞神器
- </h3>
- </a>
- </div>
- <!-- 新闻列表 -->
- <ul class="news-list">
- <li>
- <a href="#">最美门将变短视频女神 四年后回归国家队</a>
- </li>
- <li>
- <a href="#">只剩足球的许老板还能逆袭吗?</a>
- </li>
- <li>
- <a href="#">科尔G1完爆基德:“我预判了你的预判!”</a>
- </li>
- <li>
- <a href="#">印度名宿:我们已是羽毛球超级大国</a>
- </li>
- </ul>
- </div>
- </body>
- </html>
|