博客列表 >仿哔哩哔哩移动端首页

仿哔哩哔哩移动端首页

月缺
月缺原创
2021年10月01日 15:27:221391浏览

仿哔哩哔哩移动端首页

html文件结构

  1. <!-- 页面结构 -->
  2. <div class="home">
  3. <!-- 页眉 -->
  4. <header>
  5. <!-- 菜单 -->
  6. <span class="iconfont icon-bilibili-copy" style="color: red;font-size: 3rem;"></span>
  7. <!-- 搜索框 -->
  8. <div class="search">
  9. </div>
  10. <!-- 登录 -->
  11. <a href=""></a>
  12. </header>
  13. <!-- 主体 -->
  14. <div class="main">
  15. <!-- 导航区 -->
  16. <ul class="navs">
  17. <li class="item">首页</li>
  18. <li class="item">频道</li>
  19. <li class="item active">直播</li>
  20. <li class="item">排行</li>
  21. <li class="item">我的</li>
  22. </ul>
  23. <!-- 轮播图 -->
  24. <div class="slider">
  25. <div class="imgs">
  26. <a href="" class="active"><img src="static/images/banner.png" alt="" /></a>
  27. <a href=""><img src="static/images/banner.png" alt="" /></a>
  28. <a href=""><img src="static/images/banner.png" alt="" /></a>
  29. </div>
  30. <!-- 轮播图底部的切换按钮组,与轮播图数量对应 -->
  31. <div class="btns">
  32. <span class="item active"></span>
  33. <span class="item"></span>
  34. <span class="item"></span>
  35. </div>
  36. </div>
  37. <!-- 电台 -->
  38. <div class="list-container">
  39. <div class="title-ctnr">
  40. <h5>电台</h5>
  41. <small>进去看看</small>
  42. </div>
  43. <ul class="block-ctnr">
  44. <li>
  45. <div class="cover-wrap">
  46. <img src="./static/images/slides/slide1.jpg" alt="">
  47. </div>
  48. <div class="cover-cont">
  49. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  50. <div class="mov-info">
  51. <div>
  52. <span class="iconfont icon-UPzhu"></span>
  53. <span>xxxxxx</span>
  54. </div>
  55. <span class="iconfont icon-gengduo1"></span>
  56. </div>
  57. </div>
  58. </li>
  59. <li>
  60. <div class="cover-wrap">
  61. <img src="./static/images/slides/slide2.jpg" alt="">
  62. </div>
  63. <div class="cover-cont">
  64. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  65. <div class="mov-info">
  66. <div>
  67. <span class="iconfont icon-UPzhu"></span>
  68. <span>xxxxxx</span>
  69. </div>
  70. <span class="iconfont icon-gengduo1"></span>
  71. </div>
  72. </div>
  73. </li>
  74. <li>
  75. <div class="cover-wrap">
  76. <img src="./static/images/slides/slide3.jpg" alt="">
  77. </div>
  78. <div class="cover-cont">
  79. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  80. <div class="mov-info">
  81. <div>
  82. <span class="iconfont icon-UPzhu"></span>
  83. <span>xxxxxx</span>
  84. </div>
  85. <span class="iconfont icon-gengduo1"></span>
  86. </div>
  87. </div>
  88. </li>
  89. <li>
  90. <div class="cover-wrap">
  91. <img src="./static/images/slides/slide4.jpg" alt="">
  92. </div>
  93. <div class="cover-cont">
  94. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  95. <div class="mov-info">
  96. <div>
  97. <span class="iconfont icon-UPzhu"></span>
  98. <span>xxxxxx</span>
  99. </div>
  100. <span class="iconfont icon-gengduo1"></span>
  101. </div>
  102. </div>
  103. </li>
  104. </ul>
  105. </div>
  106. <!-- 视频唱见 -->
  107. <div class="list-container">
  108. <div class="title-ctnr">
  109. <h5>视频唱见</h5>
  110. <small>进去看看</small>
  111. </div>
  112. <ul class="block-ctnr">
  113. <li>
  114. <div class="cover-wrap">
  115. <img src="./static/images/slides/slide1.jpg" alt="">
  116. </div>
  117. <div class="cover-cont">
  118. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  119. <div class="mov-info">
  120. <div>
  121. <span class="iconfont icon-UPzhu"></span>
  122. <span>xxxxxx</span>
  123. </div>
  124. <span class="iconfont icon-gengduo1"></span>
  125. </div>
  126. </div>
  127. </li>
  128. <li>
  129. <div class="cover-wrap">
  130. <img src="./static/images/slides/slide2.jpg" alt="">
  131. </div>
  132. <div class="cover-cont">
  133. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  134. <div class="mov-info">
  135. <div>
  136. <span class="iconfont icon-UPzhu"></span>
  137. <span>xxxxxx</span>
  138. </div>
  139. <span class="iconfont icon-gengduo1"></span>
  140. </div>
  141. </div>
  142. </li>
  143. <li>
  144. <div class="cover-wrap">
  145. <img src="./static/images/slides/slide3.jpg" alt="">
  146. </div>
  147. <div class="cover-cont">
  148. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  149. <div class="mov-info">
  150. <div>
  151. <span class="iconfont icon-UPzhu"></span>
  152. <span>xxxxxx</span>
  153. </div>
  154. <span class="iconfont icon-gengduo1"></span>
  155. </div>
  156. </div>
  157. </li>
  158. <li>
  159. <div class="cover-wrap">
  160. <img src="./static/images/slides/slide4.jpg" alt="">
  161. </div>
  162. <div class="cover-cont">
  163. <div class="mov-detail">【3D】可爱妹妹,进来叫你靓仔</div>
  164. <div class="mov-info">
  165. <div>
  166. <span class="iconfont icon-UPzhu"></span>
  167. <span>xxxxxx</span>
  168. </div>
  169. <span class="iconfont icon-gengduo1"></span>
  170. </div>
  171. </div>
  172. </li>
  173. </ul>
  174. </div>
  175. </div>
  176. <!-- 页脚 -->
  177. <div class="footer">
  178. <div class="active">
  179. <span class="iconfont icon-shouye"></span>
  180. <span>首页</span>
  181. </div>
  182. <div>
  183. <span class="iconfont icon-dongtai"></span>
  184. <span>动态</span>
  185. </div>
  186. <div>
  187. <span class="iconfont icon-gengduo"></span>
  188. </div>
  189. <div>
  190. <span class="iconfont icon-huiyuangou"></span>
  191. <span>会员购</span>
  192. </div>
  193. <div>
  194. <span class="iconfont icon-bilibili-fill"></span>
  195. <span>我的</span>
  196. </div>
  197. </div>
  198. </div>

index.css —— 文件结构

  1. @import url(./static/css/reset.css);
  2. @import url(./static/css/home.css);
  3. @import url(./static/css/header.css);
  4. @import url(./static/css/navs.css);
  5. @import url(./static/css/slider.css);
  6. @import url(./static/css/list.css);
  7. @import url(./static/css/footer.css);

reset.css —— 重置浏览器样式

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. :root {
  7. font-size: 10px;
  8. }
  9. a {
  10. text-decoration: none;
  11. color: #666;
  12. }
  13. ul li {
  14. list-style: none;
  15. }
  16. body {
  17. font-size: 1.6rem;
  18. background-color: #f6f6f6;
  19. }
  20. /* 媒体查询 */
  21. @media (min-width: 480px) {
  22. :root {
  23. font-size: 12px;
  24. }
  25. }
  26. @media (min-width: 640px) {
  27. :root {
  28. font-size: 14px;
  29. }
  30. }
  31. @media (min-width: 720) {
  32. :root {
  33. font-size: 16px;
  34. }
  35. }

home.css —— 页面结构样式

  1. .home {
  2. min-height: 100vh;
  3. display: grid;
  4. grid-template-rows: 5rem 1fr 6rem;
  5. }
  6. .home .main {
  7. /* -webkit-overflow-scrolling: touch; */
  8. height: calc(100vh - 11rem);
  9. overflow-y: scroll;
  10. }

header.css顶部样式

  1. .home>header {
  2. background-color: #fff;
  3. display: grid;
  4. grid-template-columns: 8rem 1fr 5rem;
  5. place-items: center;
  6. }

navs.css —— 标签栏样式

  1. .home .main .navs {
  2. padding-top: .5rem;
  3. background-color: #fff;
  4. display: grid;
  5. grid-template-columns: repeat(5, 1fr);
  6. height: 3.5rem;
  7. place-items: center;
  8. }
  9. .home .main .navs .item {
  10. width: 100%;
  11. height: 100%;
  12. text-align: center;
  13. }
  14. .home .main .navs .item.active {
  15. border-bottom: .5rem solid #fb7299;
  16. }

slider.css —— 轮播图样式

  1. .home .main .slider {
  2. width: 100vw;
  3. height: 130px;
  4. position: relative;
  5. }
  6. .home .main .slider img {
  7. width: 100%;
  8. }
  9. /* 初始化时,将所有轮播图片先全部隐藏,默认只显示第一个 */
  10. /* 注意,轮播图是可点击的,图片在链接元素中,所以只需要设置a标签即可 */
  11. .home .main .slider .imgs a {
  12. display: none;
  13. }
  14. /* 默认第一个轮播图激活 */
  15. .home .main .slider .imgs a.active {
  16. display: block;
  17. }
  18. /* 切换按钮容器的样式 */
  19. .home .main .slider .btns {
  20. width: 8rem;
  21. height: 3rem;
  22. position: absolute;
  23. top: 9.5rem;
  24. right: 0em;
  25. /* flex布局,且水平居中,并上移到轮播图底部 */
  26. display: flex;
  27. justify-content: center;
  28. /* 负外距可反向移动元素,这里是向上 */
  29. }
  30. /* 切换按钮 */
  31. .home .main .slider .btns .item {
  32. height: 1.2rem;
  33. width: 1.2rem;
  34. border-radius: 50%;
  35. background-color: #fff;
  36. margin: 0.5rem;
  37. }
  38. /* 切换按钮鼠标悬停样式 */
  39. .home .main .slider .btns .item:hover {
  40. cursor: pointer;
  41. }
  42. /* 当前默认激活的按钮样式 */
  43. .home .main .slider .btns .item.active {
  44. background-color: #fb7299;
  45. }

list.css —— 主体内容列表样式

  1. .list-container {
  2. margin: 1rem 0;
  3. display: grid;
  4. grid-template-rows: 3rem 1fr;
  5. background-color: #fff;
  6. }
  7. .list-container .title-ctnr {
  8. display: flex;
  9. padding: 0 1rem;
  10. place-content: space-between;
  11. place-items: center;
  12. }
  13. .list-container .title-ctnr h5 {
  14. font-size: 1.8rem;
  15. }
  16. .list-container .title-ctnr span {
  17. color: grey;
  18. }
  19. .list-container .block-ctnr {
  20. width: 100%;
  21. padding: 0.8rem;
  22. display: grid;
  23. grid-template-columns: repeat(2, 1fr);
  24. grid-template-rows: repeat(2, 1fr);
  25. gap: 1rem;
  26. }
  27. .list-container .block-ctnr li{
  28. height: 16rem;
  29. }
  30. .list-container .block-ctnr li img {
  31. width: 100%;
  32. height: 10rem;
  33. border-radius: 1rem;
  34. }
  35. .cover-cont .mov-detail{
  36. font-size: 1.4rem;
  37. }
  38. .cover-cont .mov-info {
  39. margin-top: 0.5rem;
  40. display: flex;
  41. place-content: space-between;
  42. align-items: baseline;
  43. color: grey;
  44. }
  1. .footer {
  2. display: flex;
  3. justify-content: space-around;
  4. }
  5. .footer div{
  6. display: flex;
  7. flex-direction: column;
  8. align-items: center;
  9. justify-content: center;
  10. }
  11. .footer div .iconfont {
  12. font-size: 2.5rem;
  13. color: #383636;
  14. }
  15. .footer div span {
  16. font-size: 1rem;
  17. color: #615f5f;
  18. }
  19. .footer div.active .iconfont,.footer div.active span {
  20. color: #fb7299;
  21. }

最终效果演示

最终结果

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议
胡子2021-10-09 22:46:331楼
? 人,大佬。