用《CSS盒子模型》文章里的内容完成一个新闻列表-div布局案例
效果图
实现代码
<!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>Document</title>
<style>
*{
margin:0;
padding: 0;
box-sizing: border-box;/*內减模式*/
}
.news{
width: 500px;
height: 400px;
border: 1px solid #ccc;
margin: 50px auto;
padding: 42px 30px 0;
}
.news h2{
font-size: 30px;
border-bottom: 1px solid #ccc;
line-height: 1;/*字体1倍的大小*/
padding-bottom: 9px;
}
.news ul{
list-style: none;
}
.news ul li{
height: 50px;
border-bottom: 1px dashed #ccc;
line-height: 50px;
padding-left: 28px;
}
.news a{
text-decoration: none;
color: #666;
font-size: 18px;
}
</style>
</head>
<body>
<div class="news">
<h2>最新文章/New Articles</h2>
<ul>
<li><a href="#">《余生,请多指教》热播 杨紫肖战在爱中相伴成长</a></li>
<li><a href="#">《尘缘》电影版开机 陈嘉上执导打造东方玄幻传奇</a></li>
<li><a href="#">你能想到的他都会,近距离看看冬奥会上的机器人</a></li>
<li><a href="#">元宇宙到来的时候,不会再叫“元宇宙”</a></li>
<li><a href="#">每天爬楼520层,为啥才瘦一点点?</a></li>
</ul>
</div>
</body>
</html>