html:
(1)每次都要引入reset.css文件
(2)合理的先推敲整个文件的结构,特别是块
(3)li中包含每一个超链接a
css:
(1)先对body设置一个整体字符大小和颜色
(2)整个完整的块元素进行设置,必须设置块元素高宽,才能通过设置margin: 50px auto;来控制块元素在页面中的布局,同时设置一条线段时,通过border-top(或者其他三个方位): xxx;来设置
(3)对h2块元素进行设置时,设置字体为粗体,要使用font-weight: bold;, 为了避免红线和上一个块元素的线不重合,通过对h2块元素设置 display: inline-block;来进行设置为行块元素,就可以重合了
(4)去掉链接的下划线,使用text-decoration: none;来使用
(5)写css主义元素从上至下,从祖先到后代
财经
<div class="news-img">
<a href="#">
<img src="../img/1.webp" alt="财经">
<h2 class="img-title">
蚂蚁花呗额度"被砍"
</h2>
</a>
</div>
<ul class="news-column">
<li>
<a href="#" >特朗普离任前"最后一战" 或针对这个国家?</a>
</li>
<li>
<a href="#" >不止年终奖、十三薪 年底还有这几笔钱能领</a>
</li>
<li>
<a href="#" >李克强:对非法集资行为 要时刻瞪大眼睛</a>
</li>
<li>
<a href="#" >道指涨0.38% 万达体育将从纳斯达克退市</a>
</li>
</ul>
</div>
``
body {
font-size: 14px;
color: #666666;
}
.news-section {
border-top: #DDDDDD solid 1px;
width: 300px;
height: 349px;
margin: 50px auto;
border-bottom: #DDDDDD solid 1px;
}
.news-title {
width: 32px;
font-size: 16px;
font-weight: bold;
color: #4F4F4F;
font-family: sans-serif;
padding-top: 10px;
padding-bottom: 10px;
border-top: solid 1px #F34540;
display: inline-block;
}
.news-title a {
color: #4F4F4F;
text-decoration: none;
}
.news-title a:hover {
color: #F78481;
}
.news-img .img-title {
margin-top: -20px;
color:#FFFFFF;
font-size: 16px;
font-weight: bold;
padding-left: 30px;
}
.news-column {
height: 19px;
line-height: 19px;
}
.news-column li {
height: 20px;
}
.news-column li:nth-child(n) {
padding-top: 10px;
}
.news-column a {
color: #666666;
text-decoration: none;
padding-left: 15px;
}
.news-column a:hover {
color:#F78481;
}