效果图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模仿今日头条</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
li {
list-style: none;
}
/* 这里是外面的大盒子,设置高度350像素和宽度230像素,距离底部100像素,整个盒子设置10像素的圆角*/
.box{
width: 350px;
height: 230px;
margin: 100px auto;
border-radius: 10px;
}
/* begin 顶部的标题区,高度为40像素*/
.header {
height: 40px;
}
/* 设置图片高度30像素,vertical-align 为bottom,这样文字和图片底部对象*/
.header .title img{
height: 30px;
vertical-align: bottom;
}
.header .switch img{
height: 25px;
vertical-align: bottom;
}
.title {
float: left;
font-size: 20px;
padding-left: 10px;
}
.switch {
float: right;
font-size: 14px;
padding-right: 10px;
}
/* end */
/*begin 文章内容区*/
.content {
margin-top: 10px;
margin-left: 10px;
}
.content li {
height: 40px;
line-height: 40px;
}
.content li div {
display: inline-block;
font-size: 20px;
font-weight: 700;
color: #A8A8A8;
}
.content li div:hover {
cursor: pointer;
}
.content li a {
font-size: 16px;
margin-left: 10px;
}
.content li a:hover {
color: red;
cursor: pointer;
}
.hot {
width: 20px;
height: 20px;
border-radius: 5px;
background: red;
line-height: 20px;
}
.content li div:nth-child(3) {
color: white;
font-size: 12px;
text-align: center;
}
#heng{
display: block;
width:10px;
height:2px;
background-color:red;
margin-bottom: -4px;
}
/* 向下箭头 */
#to_top {
width: 0;
height: 0;
border-top: 5px solid transparent;
border-bottom: 5px solid red;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
display: block;
}
#line{
display: block;
width:2px;
height:10px;
background-color:red;
margin-left: 4px;
}
#number1 {
color: #D9A5A5;
}
#number2 {
color: #F36D6E;
}
#number3 {
color: #FF9A03;
}
/* end 文章内容区*/
</style>
</head>
<body>
<div class="box">
<div class="header">
<div class="title">
<img src="image1.png" />
<span>头条热榜</span>
</div>
<div class="switch">
<img src="image2.png" />
<span>换一换</span>
</div>
</div>
<div class="content">
<ul>
<li>
<div>
<div id="heng"></div>
<div id="to_top"></div>
<div id="line"></div>
</div>
<a>构建网络空间命运共同体</a>
</li>
<li>
<div id="number1">1</div>
<a>印尼总统称强烈感觉普京不出席G20</a>
<div class="hot" >热</div>
</li>
<li>
<div id="number2">2</div>
<a>小伙买房买贵了放弃5万定金毁约</a>
<div class="hot" >热</div>
</li>
<li>
<div id="number3">3</div>
<a>携手构建网络空间命运共同体</a>
</li>
<li>
<div>4</div>
<a>泽连斯基将参加G20峰会</a>
<div class="hot" >热</div>
</li>
<li>
<div>5</div>
<a>文旅局长被吐槽像如花 女儿当表情包</a>
</li>
<li>
<div>6</div>
<a>老太借房给重孙上学 孙子却拒还</a>
</li>
</ul>
</div>
</div>
</body>
</html>