程序实现
<div class="header">
<div class="search">
<div class="keys">
<span class="iconfont icon-sousuo"></span>
<span>搜你想看的</span>
</div>
<div class="publish">
<span class="iconfont icon-fabu"></span>
<span class="text">发布</span>
</div>
</div>
<div class="navs">
<a href="">关注</a>
<a href="" class="active">推荐</a>
<a href="">探索</a>
<a href="">发现</a>
<a href="">防疫</a>
<a href="">国际</a>
</div>
</div>
<!-- main -->
<div class="main">
<!-- 置顶 -->
<div class="top-list">
<a class="top" href="">
<div class="title">习近平同俄罗斯总统普京举行会谈</div>
<div class="comment">
<span class="highlight">置顶</span>
<span class="focus">已关注</span>
<span>·</span>
<span class="source">央视新闻</span>
<span class="follow">918评论</span>
</div>
</a>
</div>
<div class="top-list">
<a class="top" href="">
<div class="title">
习近平同俄罗斯总统普京举行会谈,会见总理米舒斯金
</div>
<div class="comment">
<span class="highlight">置顶</span>
<span class="focus">已关注</span>
<span>·</span>
<span class="source">央视新闻</span>
<span class="follow">918评论</span>
</div>
</a>
</div>
<!-- 文字+图片 -->
<div class="miximg-list">
<a href="" class="miximg">
<div class="content">
<div class="title">
!总台独家专访|美海军陆战队前队员:“北溪”被炸无限期损害欧洲工业竞争力
</div>
<div class="comment">
<span class="source">国际在线</span>
<span class="follow">3评论</span>
<span class="time">1小时前</span>
</div>
</div>
<div class="imgs">
<img
src="https://p3-sign.toutiaoimg.com/tos-cn-i-tjoges91tu/TZ6HuHD8suI5cx~noop.image?x-expires=1994821336&x-signature=946ahttTmcXqDBm1GQ6Jn6MmvnU%3D"
alt=""
/>
</div>
</a>
</div>
<div class="miximg-lists">
<a href="" class="miximg">
<div class="content">
<div class="title">
总台独家专访|美海军陆战队前队员:“北溪”被炸无限期损害欧洲工业竞争力
</div>
<div class="comment">
<span class="source">国际在线</span>
<span class="follow">3评论</span>
<span class="time">1小时前</span>
</div>
</div>
<img
src="https://p3-sign.toutiaoimg.com/tos-cn-i-tjoges91tu/TZ6HuHD8suI5cx~noop.image?x-expires=1994821336&x-signature=946ahttTmcXqDBm1GQ6Jn6MmvnU%3D"
alt=""
/>
</a>
</div>
<!-- 文字+视频 -->
<div class="mixvideo">
<a class="title" href="">夜线约见:高校开设“考公”培训班?</a>
<video src="static/images/Qi8_eweH.mp4" controls></video>
<div class="comment">
<span class="source">看看新闻</span>
<span class="follow">3评论</span>
<span class="time">1小时前</span>
</div>
</div>
<div class="mixvideo">
<a class="title" href=""
>聊天记录曝光!“女子杀夫藏尸案”亲人曾给被害人发信息怀疑对方不是本人</a
>
<video
src="https://edge.ivideo.sina.com.cn/50328897401.mp4?KID=sina,viask&Expires=1679587200&ssig=oZGhgzRi0w&reqid="
controls
></video>
<div class="comment">
<span class="source">新浪新闻</span>
<span class="follow">15评论</span>
<span class="time">1天前</span>
</div>
</div>
</div>
<!-- footer -->
<div class="foot">
<a class="item active" href="">
<span class="iconfont icon-wenjianliebiao2"></span>
<span class="icontext">首页</span>
</a>
<a class="item" href="">
<span class="iconfont icon-24gl-play"></span>
<span class="icontext">视频</span>
</a>
<a class="item" href="">
<span class="iconfont icon-dianshi"></span>
<span class="icontext">放映厅</span>
</a>
<a class="item" href="">
<span class="iconfont icon-wodewo"></span>
<span class="icontext">我的</span>
</a>
</div>
/* header css */
.header {
position: fixed;
/* initial css设置了padding,如下设置可以覆盖掉padding,将背景全覆盖 */
left: 0;
top: 0;
right: 0;
background-color: red;
z-index: 999;
}
.header .search {
/* display: flex;
place-content: space-between; */
/* 采用grid布局,可以设置两个单元格宽度 */
display: grid;
grid-template-columns: 1fr 0.5rem;
padding: 0.08rem;
}
.header .search .keys {
background-color: white;
color: lightgray;
border-radius: 2rem;
padding: 0.1rem 0.2rem;
}
.header .search .publish {
display: grid;
place-items: center;
color: white;
}
.header .navs {
background-color: white;
display: flex;
place-content: space-around;
padding: 0.05rem 0;
border-bottom: 0.01rem solid lightgray;
}
.header .navs a {
position: relative;
color: gray;
}
.header .navs a.active::after {
position: absolute;
content: "";
/* 用bottom而不是margin-top,bottom为a的相对定位底部,left为a的相对定位左边 */
bottom: -0.04rem;
left: 0;
width: 0.32rem;
height: 0.03rem;
background-color: red;
}
/* main css */
.main {
position: absolute;
/* left: 0;
right: 0; */
top: 1rem;
padding-bottom: 0.5rem;
background-color: white;
/* height: 10rem; */
}
.main .comment {
/* 下边距 */
display: flex;
font-size: small;
color: lightgray;
gap: 0.1rem;
/* color: aqua; */
}
/* 1. 置顶 css */
.main .top-list {
display: block;
margin-top: 0.1rem;
}
.main .top-list .top .comment .highlight {
color: red;
}
.main .miximg-list,
.main .miximg-lists {
margin-top: 0.1rem;
}
/* 1. 文字+图片flex css */
.main .miximg-list .miximg {
/* 采用grid布局,实现宽度定制 */
/* display: grid;
grid-template-columns: 1fr 1.4rem; */
display: flex;
flex-flow: row nowrap;
/* display: block后,padding设置有效; */
padding: 0.03rem 0.1rem 0 0;
gap: 0.03rem;
}
.main .miximg-list .miximg .content {
/* padding-right: 0.1rem; */
flex: 100;
}
.main .miximg-list .miximg .imgs {
/* display: block; */
/* padding-right: 0.1rem; */
flex: 1.2rem;
place-self: center;
}
/* 1. 文字+图片grid css */
.main .miximg-lists .miximg {
/* 采用grid布局,实现宽度定制 */
display: grid;
grid-template-columns: 1fr 1.2rem;
padding: 0.03rem 0.1rem 0 0;
gap: 0.03rem;
}
.main .miximg-lists .miximg a img {
padding-right: 0.1rem;
}
.main .mixvideo {
margin-top: 0.1rem;
display: block;
gap: 0.05rem;
padding: 0 0.1rem 0 0;
}
/* .main .mixvideo {
display: block;
gap: 0.1rem;
} */
/* footer css */
.foot {
/* 固定页脚 */
position: fixed;
/* 固定在底部,左右齐边 */
left: 0;
right: 0;
bottom: 0;
display: flex;
place-content: space-around;
background-color: rgb(253, 252, 252);
z-index: 888;
}
.foot .item {
color: gray;
}
.foot .item {
display: grid;
/* font-size: normal; */
/* grid->place-items: 单于格水平对齐; */
place-items: center;
/* color: red; */
}
.foot .item .iconfont {
font-size: 0.2rem;
}
.foot .item .icontext {
font-size: small;
}
/* 有两个class属性的项目,css中两个class name连写 */
.foot .item.active {
color: red;
}
实现效果