Blogger Information
Blog 29
fans 0
comment 0
visits 14071
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
移动端布局学习小结与实践
P粉317509817
Original
354 people have browsed it

移动端布局知识点

序号 名称 描述
1 像素 图像显示最小单位,PPI(像素分辨率)
2 DPR 设备像素比 = 设备像素 / CSS 像素
3 视口 可视窗口 viewport,分布局/视觉/理想三类
序号 名称 描述
1 布局视口Layout viewport 设备无关, 通常默认980px,显示完整网页
2 视觉视口visual viewport 设备相关,用户手机屏幕可见部分,通过缩放查看全部
3 理想视口idea viewport 不必缩放就可查看全部,针对移动端进行布局
序号 属性值 描述
1 width=device-width 布局视图 = 视觉视图
2 initial-scale=1.0 视觉视图 = 理想视图
序号 属性值 描述
1 1vw = 3.75px iPhone6/11屏幕宽度为基准
2 1rem = 100vw / 3.75 1rem = 100px, 方便计算

淘宝页面仿写

html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="stylesheet" href="icon_font/iconfont.css" />
  8. <link rel="stylesheet" href="css/reset.css" />
  9. <link rel="stylesheet" href="css/header.css" />
  10. <link rel="stylesheet" href="css/footer.css">
  11. <link rel="stylesheet" href="css/main.css">
  12. <title>淘宝移动端仿写</title>
  13. </head>
  14. <body>
  15. <!-- 页眉 -->
  16. <header>
  17. <!-- 顶部 -->
  18. <div class="top">
  19. <!-- logo -->
  20. <div class="logo iconfont icon-shejiaotubiao-08"></div>
  21. <!-- 搜索框 -->
  22. <div class="search">
  23. <div class="key">
  24. <span class="iconfont icon-fangdajing"></span>
  25. <span>寻找宝贝店铺</span>
  26. </div>
  27. </div>
  28. </div>
  29. <!-- 轮播图 -->
  30. <div class="slider">
  31. <a href=""><img src="images/banner/banner1.jpg" alt=""></a>
  32. </div>
  33. <!-- 导航组 -->
  34. <ul class="nav">
  35. <li class="item">
  36. <a href=""><img src="images/nav/nav6.png"alt=""></a>
  37. <a href="">天猫新品</a>
  38. </li>
  39. <li class="item">
  40. <a href=""><img src="images/nav/nav3.png" alt=""></a>
  41. <a href="">今日爆款</a>
  42. </li>
  43. <li class="item">
  44. <a href=""><img src="images/nav/nav1.png" alt=""></a>
  45. <a href="">天猫超市</a>
  46. </li>
  47. <li class="item">
  48. <a href=""><img src="images/nav/nav2.png" alt=""></a>
  49. <a href="">充值中心</a>
  50. </li>
  51. <li class="item">
  52. <a href=""><img src="images/nav/nav5.png" alt=""></a>
  53. <a href="">机票酒店</a>
  54. </li>
  55. <li class="item">
  56. <a href=""><img src="images/nav/nav8.png" alt=""></a>
  57. <a href="">金币庄园</a>
  58. </li>
  59. <li class="item">
  60. <a href=""><img src="images/nav/nav7.png" alt=""></a>
  61. <a href="">阿里拍卖</a>
  62. </li>
  63. <li class="item">
  64. <a href=""><img src="images/nav/nav4.png" alt=""></a>
  65. <a href="">分类</a>
  66. </li>
  67. </ul>
  68. </header>
  69. <main>
  70. <div class="goods-nav">
  71. <div class="juhuasuan">
  72. <div class="context ">
  73. <span class="title">聚划算</span>
  74. <a href=""class="pingpaizhekou">
  75. <span>品牌折扣</span>
  76. <img src="images/items/item1.png" alt="">
  77. </a>
  78. <a href="" class="huasuanhaowu">
  79. <span>划算好物</span>
  80. <img src="images/items/item2.png" alt="">
  81. </a>
  82. </div>
  83. </div>
  84. <div class="juhuasuan">
  85. <div class="context">
  86. <span class="title">聚划算</span>
  87. <a href=""class="pingpaizhekou">
  88. <span>品牌折扣</span>
  89. <img src="images/items/item1.png" alt="">
  90. </a>
  91. <a href="" class="huasuanhaowu">
  92. <span>划算好物</span>
  93. <img src="images/items/item2.png" alt="">
  94. </a>
  95. </div>
  96. </div>
  97. <div class="juhuasuan">
  98. <div class="context">
  99. <span class="title">聚划算</span>
  100. <a href=""class="pingpaizhekou">
  101. <span>品牌折扣</span>
  102. <img src="images/items/item1.png" alt="">
  103. </a>
  104. <a href="" class="huasuanhaowu">
  105. <span>划算好物</span>
  106. <img src="images/items/item2.png" alt="">
  107. </a>
  108. </div>
  109. </div>
  110. <div class="juhuasuan">
  111. <div class="context">
  112. <span class="title">聚划算</span>
  113. <a href=""class="pingpaizhekou">
  114. <span>品牌折扣</span>
  115. <img src="images/items/item1.png" alt="">
  116. </a>
  117. <a href="" class="huasuanhaowu">
  118. <span>划算好物</span>
  119. <img src="images/items/item2.png" alt="">
  120. </a>
  121. </div>
  122. </div>
  123. <div class="juhuasuan">
  124. <div class="context">
  125. <span class="title">聚划算</span>
  126. <a href=""class="pingpaizhekou">
  127. <span>品牌折扣</span>
  128. <img src="images/items/item1.png" alt="">
  129. </a>
  130. <a href="" class="huasuanhaowu">
  131. <span>划算好物</span>
  132. <img src="images/items/item2.png" alt="">
  133. </a>
  134. </div>
  135. </div>
  136. <div class="juhuasuan">
  137. <div class="context">
  138. <span class="title">聚划算</span>
  139. <a href=""class="pingpaizhekou">
  140. <span>品牌折扣</span>
  141. <img src="images/items/item1.png" alt="">
  142. </a>
  143. <a href="" class="huasuanhaowu">
  144. <span>划算好物</span>
  145. <img src="images/items/item2.png" alt="">
  146. </a>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="bottom">
  151. <div class="context">
  152. <span style="font-size: 0.2rem; font-weight:0.5rem;margin:0.1rem;">淘宝头条</span>
  153. <span><em style="background-color: coral;color: aliceblue;font-size: normal;border-radius: 0.05rem;padding: auto;margin: auto;">摄影</em>摄影xxxxxxx</span>
  154. </div>
  155. </div>
  156. </main>
  157. <footer>
  158. <div class="item active">
  159. <a href="" class="iconfont icon-shejiaotubiao-44"></a>
  160. </div>
  161. <div class="item">
  162. <a href="" class="iconfont icon-gouwuche"></a>
  163. <a href="">购物车</a>
  164. </div>
  165. <div class="item">
  166. <a href="" class="iconfont icon-wodetaobao"></a>
  167. <a href="">我的淘宝</a>
  168. </div>
  169. </footer>
  170. </body>
  171. </html>

css

  1. header {
  2. position: relative;
  3. }
  4. header .top {
  5. width: 100vw;
  6. background-color: coral;
  7. position: fixed;
  8. top: 0;
  9. left: 0;
  10. right: 0;
  11. display: grid;
  12. grid-template-columns: 0.35rem 1fr;
  13. padding: 0.05rem;
  14. /* 调整显示层级 */
  15. z-index: 99;
  16. }
  17. header .top .logo {
  18. color: white;
  19. font-size: 0.25rem;
  20. }
  21. header .top .search {
  22. background-color: orangered;
  23. color: #eee;
  24. display: grid;
  25. place-content: center;
  26. border-radius: 0.05rem;
  27. font-size: small;
  28. }
  29. .slider{
  30. height: 1.25rem;
  31. position: absolute;
  32. top: 0.35rem;
  33. }
  34. .slider img,
  35. .nav img{
  36. width: 100%;
  37. height: 100%;
  38. }
  39. header .nav {
  40. background-color: #fff;
  41. position: absolute;
  42. top: calc(0.35rem + 1.25rem);
  43. display: grid;
  44. grid-template-columns: repeat(5, 1fr);
  45. font-size: 0.11rem;
  46. /* padding: 0.2rem 0.1rem; */
  47. column-gap: 0.05rem;
  48. row-gap: 0.1rem;
  49. margin-top: .06rem;
  50. }
  51. header .nav .item {
  52. display: grid;
  53. place-items: center;
  54. padding: 0.05rem 0.05rem;
  55. }
  56. header .nav .item a {
  57. padding: 0 0.05rem;
  58. }
  59. footer {
  60. width: 100vw;
  61. height: 0.46rem;
  62. background-color: #fff;
  63. position: fixed;
  64. bottom: 0;
  65. left: 0;
  66. right: 0;
  67. display: grid;
  68. grid-template-columns: repeat(3, 1fr);
  69. place-items: center;
  70. }
  71. footer .item {
  72. display: grid;
  73. place-items: center;
  74. }
  75. footer .item .iconfont {
  76. font-size: 0.2rem;
  77. }
  78. footer .item.active .iconfont {
  79. font-size: 0.36rem;
  80. color: coral;
  81. }
  82. main {
  83. position:relative;
  84. }
  85. main .goods-nav{
  86. /* background-color: #fff; */
  87. margin:auto;
  88. position: absolute;
  89. top: calc(0.36rem + 1.3rem + 1.52rem);
  90. display: grid;
  91. grid-template-columns: repeat(2, 1.86rem);
  92. grid-template-rows: repeat(3, 1.26rem);
  93. column-gap: 0.02rem;
  94. }
  95. main .goods-nav .juhuasuan{
  96. background-color: #fff;
  97. }
  98. main .goods-nav .juhuasuan .context{
  99. display: grid;
  100. grid-template-columns: repeat(2,1fr);
  101. grid-template-rows: 0.26rem 1rem;
  102. place-content: center;
  103. place-items: center;
  104. }
  105. main .goods-nav .juhuasuan .context span {
  106. font-weight: bolder;
  107. }
  108. main .goods-nav .juhuasuan .context .title {
  109. grid-column: span 2;
  110. font-size: large;
  111. font-weight: bolder;
  112. place-self: start;
  113. padding: 0 0 0 0.03rem;
  114. margin-left: 0.1rem;
  115. }
  116. main .goods-nav img{
  117. width: 100%;
  118. height: 100%;
  119. }
  120. main .goods-nav .context .pingpaizhekou {
  121. place-self: center;
  122. background-color:rgb(255,127,80,0.2);
  123. border-radius: 0.05rem;
  124. margin-left: 0.1rem;
  125. margin-right: 0.04rem;
  126. }
  127. main .goods-nav .context .pingpaizhekou span{
  128. margin: 0.1rem;
  129. padding: auto;
  130. font-weight: bolder;
  131. /* color: darkpink; */
  132. }
  133. main .goods-nav .context .huasuanhaowu {
  134. place-self: center;
  135. background-color:rgb(255,69,0,0.3);
  136. border-radius: 0.05rem;
  137. margin-left: 0.04rem;
  138. margin-right: 0.1rem;
  139. }
  140. main .goods-nav .context .huasuanhaowu span{
  141. margin: 0.1rem;
  142. padding: auto;
  143. font-weight: bolder;
  144. /* color: darkpink; */
  145. }
  146. main .bottom {
  147. margin: auto;
  148. position: relative;
  149. top:7.03rem;
  150. background-color: #fff;
  151. width: 100%;
  152. height: 0.42rem;
  153. border-radius: 0 0 0.1rem 0.1rem;
  154. }
  155. main .bottom .context{
  156. display: flex;
  157. place-content: start;
  158. place-items: center;
  159. }

效果:

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post