仿头条首页

编辑: admin 分类: 电脑知识 发布时间: 2023-06-14 来源:互联网
程序实现
  1. <div class="header">
  2. <div class="search">
  3. <div class="keys">
  4. <span class="iconfont icon-sousuo"></span>
  5. <span>搜你想看的</span>
  6. </div>
  7. <div class="publish">
  8. <span class="iconfont icon-fabu"></span>
  9. <span class="text">发布</span>
  10. </div>
  11. </div>
  12. <div class="navs">
  13. <a href="">关注</a>
  14. <a href="" class="active">推荐</a>
  15. <a href="">探索</a>
  16. <a href="">发现</a>
  17. <a href="">防疫</a>
  18. <a href="">国际</a>
  19. </div>
  20. </div>
  21. <!-- main -->
  22. <div class="main">
  23. <!-- 置顶 -->
  24. <div class="top-list">
  25. <a class="top" href="">
  26. <div class="title">习近平同俄罗斯总统普京举行会谈</div>
  27. <div class="comment">
  28. <span class="highlight">置顶</span>
  29. <span class="focus">已关注</span>
  30. <span>·</span>
  31. <span class="source">央视新闻</span>
  32. <span class="follow">918评论</span>
  33. </div>
  34. </a>
  35. </div>
  36. <div class="top-list">
  37. <a class="top" href="">
  38. <div class="title">
  39. 习近平同俄罗斯总统普京举行会谈,会见总理米舒斯金
  40. </div>
  41. <div class="comment">
  42. <span class="highlight">置顶</span>
  43. <span class="focus">已关注</span>
  44. <span>·</span>
  45. <span class="source">央视新闻</span>
  46. <span class="follow">918评论</span>
  47. </div>
  48. </a>
  49. </div>
  50. <!-- 文字+图片 -->
  51. <div class="miximg-list">
  52. <a href="" class="miximg">
  53. <div class="content">
  54. <div class="title">
  55. !总台独家专访|美海军陆战队前队员:“北溪”被炸无限期损害欧洲工业竞争力
  56. </div>
  57. <div class="comment">
  58. <span class="source">国际在线</span>
  59. <span class="follow">3评论</span>
  60. <span class="time">1小时前</span>
  61. </div>
  62. </div>
  63. <div class="imgs">
  64. <img
  65. src="https://p3-sign.toutiaoimg.com/tos-cn-i-tjoges91tu/TZ6HuHD8suI5cx~noop.image?x-expires=1994821336&x-signature=946ahttTmcXqDBm1GQ6Jn6MmvnU%3D"
  66. alt=""
  67. />
  68. </div>
  69. </a>
  70. </div>
  71. <div class="miximg-lists">
  72. <a href="" class="miximg">
  73. <div class="content">
  74. <div class="title">
  75. 总台独家专访|美海军陆战队前队员:“北溪”被炸无限期损害欧洲工业竞争力
  76. </div>
  77. <div class="comment">
  78. <span class="source">国际在线</span>
  79. <span class="follow">3评论</span>
  80. <span class="time">1小时前</span>
  81. </div>
  82. </div>
  83. <img
  84. src="https://p3-sign.toutiaoimg.com/tos-cn-i-tjoges91tu/TZ6HuHD8suI5cx~noop.image?x-expires=1994821336&x-signature=946ahttTmcXqDBm1GQ6Jn6MmvnU%3D"
  85. alt=""
  86. />
  87. </a>
  88. </div>
  89. <!-- 文字+视频 -->
  90. <div class="mixvideo">
  91. <a class="title" href="">夜线约见:高校开设“考公”培训班?</a>
  92. <video src="static/images/Qi8_eweH.mp4" controls></video>
  93. <div class="comment">
  94. <span class="source">看看新闻</span>
  95. <span class="follow">3评论</span>
  96. <span class="time">1小时前</span>
  97. </div>
  98. </div>
  99. <div class="mixvideo">
  100. <a class="title" href=""
  101. >聊天记录曝光!“女子杀夫藏尸案”亲人曾给被害人发信息怀疑对方不是本人</a
  102. >
  103. <video
  104. src="https://edge.ivideo.sina.com.cn/50328897401.mp4?KID=sina,viask&Expires=1679587200&ssig=oZGhgzRi0w&reqid="
  105. controls
  106. ></video>
  107. <div class="comment">
  108. <span class="source">新浪新闻</span>
  109. <span class="follow">15评论</span>
  110. <span class="time">1天前</span>
  111. </div>
  112. </div>
  113. </div>
  114. <!-- footer -->
  115. <div class="foot">
  116. <a class="item active" href="">
  117. <span class="iconfont icon-wenjianliebiao2"></span>
  118. <span class="icontext">首页</span>
  119. </a>
  120. <a class="item" href="">
  121. <span class="iconfont icon-24gl-play"></span>
  122. <span class="icontext">视频</span>
  123. </a>
  124. <a class="item" href="">
  125. <span class="iconfont icon-dianshi"></span>
  126. <span class="icontext">放映厅</span>
  127. </a>
  128. <a class="item" href="">
  129. <span class="iconfont icon-wodewo"></span>
  130. <span class="icontext">我的</span>
  131. </a>
  132. </div>
  1. /* header css */
  2. .header {
  3. position: fixed;
  4. /* initial css设置了padding,如下设置可以覆盖掉padding,将背景全覆盖 */
  5. left: 0;
  6. top: 0;
  7. right: 0;
  8. background-color: red;
  9. z-index: 999;
  10. }
  11. .header .search {
  12. /* display: flex;
  13. place-content: space-between; */
  14. /* 采用grid布局,可以设置两个单元格宽度 */
  15. display: grid;
  16. grid-template-columns: 1fr 0.5rem;
  17. padding: 0.08rem;
  18. }
  19. .header .search .keys {
  20. background-color: white;
  21. color: lightgray;
  22. border-radius: 2rem;
  23. padding: 0.1rem 0.2rem;
  24. }
  25. .header .search .publish {
  26. display: grid;
  27. place-items: center;
  28. color: white;
  29. }
  30. .header .navs {
  31. background-color: white;
  32. display: flex;
  33. place-content: space-around;
  34. padding: 0.05rem 0;
  35. border-bottom: 0.01rem solid lightgray;
  36. }
  37. .header .navs a {
  38. position: relative;
  39. color: gray;
  40. }
  41. .header .navs a.active::after {
  42. position: absolute;
  43. content: "";
  44. /* 用bottom而不是margin-top,bottom为a的相对定位底部,left为a的相对定位左边 */
  45. bottom: -0.04rem;
  46. left: 0;
  47. width: 0.32rem;
  48. height: 0.03rem;
  49. background-color: red;
  50. }
  51. /* main css */
  52. .main {
  53. position: absolute;
  54. /* left: 0;
  55. right: 0; */
  56. top: 1rem;
  57. padding-bottom: 0.5rem;
  58. background-color: white;
  59. /* height: 10rem; */
  60. }
  61. .main .comment {
  62. /* 下边距 */
  63. display: flex;
  64. font-size: small;
  65. color: lightgray;
  66. gap: 0.1rem;
  67. /* color: aqua; */
  68. }
  69. /* 1. 置顶 css */
  70. .main .top-list {
  71. display: block;
  72. margin-top: 0.1rem;
  73. }
  74. .main .top-list .top .comment .highlight {
  75. color: red;
  76. }
  77. .main .miximg-list,
  78. .main .miximg-lists {
  79. margin-top: 0.1rem;
  80. }
  81. /* 1. 文字+图片flex css */
  82. .main .miximg-list .miximg {
  83. /* 采用grid布局,实现宽度定制 */
  84. /* display: grid;
  85. grid-template-columns: 1fr 1.4rem; */
  86. display: flex;
  87. flex-flow: row nowrap;
  88. /* display: block后,padding设置有效; */
  89. padding: 0.03rem 0.1rem 0 0;
  90. gap: 0.03rem;
  91. }
  92. .main .miximg-list .miximg .content {
  93. /* padding-right: 0.1rem; */
  94. flex: 100;
  95. }
  96. .main .miximg-list .miximg .imgs {
  97. /* display: block; */
  98. /* padding-right: 0.1rem; */
  99. flex: 1.2rem;
  100. place-self: center;
  101. }
  102. /* 1. 文字+图片grid css */
  103. .main .miximg-lists .miximg {
  104. /* 采用grid布局,实现宽度定制 */
  105. display: grid;
  106. grid-template-columns: 1fr 1.2rem;
  107. padding: 0.03rem 0.1rem 0 0;
  108. gap: 0.03rem;
  109. }
  110. .main .miximg-lists .miximg a img {
  111. padding-right: 0.1rem;
  112. }
  113. .main .mixvideo {
  114. margin-top: 0.1rem;
  115. display: block;
  116. gap: 0.05rem;
  117. padding: 0 0.1rem 0 0;
  118. }
  119. /* .main .mixvideo {
  120. display: block;
  121. gap: 0.1rem;
  122. } */
  123. /* footer css */
  124. .foot {
  125. /* 固定页脚 */
  126. position: fixed;
  127. /* 固定在底部,左右齐边 */
  128. left: 0;
  129. right: 0;
  130. bottom: 0;
  131. display: flex;
  132. place-content: space-around;
  133. background-color: rgb(253, 252, 252);
  134. z-index: 888;
  135. }
  136. .foot .item {
  137. color: gray;
  138. }
  139. .foot .item {
  140. display: grid;
  141. /* font-size: normal; */
  142. /* grid->place-items: 单于格水平对齐; */
  143. place-items: center;
  144. /* color: red; */
  145. }
  146. .foot .item .iconfont {
  147. font-size: 0.2rem;
  148. }
  149. .foot .item .icontext {
  150. font-size: small;
  151. }
  152. /* 有两个class属性的项目,css中两个class name连写 */
  153. .foot .item.active {
  154. color: red;
  155. }
实现效果

仿头条首页

【文章由韩国大带宽服务器 http://www.558idc.com/lg.html处的文章,转载请说明出处】