Blogger Information
Blog 15
fans 1
comment 1
visits 174140
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
移动端布局的三种视口之间的转换关系和淘宝基本布局
想做肥仔
Original
1004 people have browsed it

1.三种视口的转换关系

  1. 1.布局视口 向转换 视觉视口转换,让布局视口 = 视觉视口
  2. width = device-width
  3. 2.视觉视口 = 理想视图 让移动端页面禁用缩放功能initial-scale=1.0
  4. 布局单位 px 改为 rem+vw,设定rem的值确定vw的值
  5. 375px的移动端设备的,vw的值的=375/100 = 3.75
  6. 为了方便布局,通常设置 1rem = 100px

2.淘宝基本布局

HTML部分

  1. <!-- 页眉 -->
  2. <header>
  3. <!-- 顶部区域 -->
  4. <div class="top">
  5. <!-- logo部分 -->
  6. <div class="logo iconfont icon-shejiaotubiao-08"></div>
  7. <!-- 搜索框区域 -->
  8. <div class="search">
  9. <div class="keys">
  10. <span class="iconfont icon-fangdajing"></span>
  11. <span>寻找宝贝店铺</span>
  12. </div>
  13. </div>
  14. </div>
  15. <!-- 轮播图 -->
  16. <div class="slider">
  17. <a href=""><img src="images/banner/banner1.jpg" alt="" /></a>
  18. </div>
  19. <!-- 导航组 -->
  20. <!-- 导航组 -->
  21. <ul class="nav">
  22. <li class="item">
  23. <a href=""><img src="images/nav/nav6.png" alt="" /></a>
  24. <a href="">天猫新品</a>
  25. </li>
  26. <li class="item">
  27. <a href=""><img src="images/nav/nav3.png" alt="" /></a>
  28. <a href="">今日爆款</a>
  29. </li>
  30. <li class="item">
  31. <a href=""><img src="images/nav/nav1.png" alt="" /></a>
  32. <a href="">天猫超市</a>
  33. </li>
  34. <li class="item">
  35. <a href=""><img src="images/nav/nav2.png" alt="" /></a>
  36. <a href="">充值中心</a>
  37. </li>
  38. <li class="item">
  39. <a href=""><img src="images/nav/nav5.png" alt="" /></a>
  40. <a href="">机票酒店</a>
  41. </li>
  42. <li class="item">
  43. <a href=""><img src="images/nav/nav8.png" alt="" /></a>
  44. <a href="">金币庄园</a>
  45. </li>
  46. <li class="item">
  47. <a href=""><img src="images/nav/nav7.png" alt="" /></a>
  48. <a href="">阿里拍卖</a>
  49. </li>
  50. <li class="item">
  51. <a href=""><img src="images/nav/nav4.png" alt="" /></a>
  52. <a href="">分类</a>
  53. </li>
  54. <li class="item">
  55. <a href=""><img src="images/nav/nav7.png" alt="" /></a>
  56. <a href="">阿里拍卖</a>
  57. </li>
  58. <li class="item">
  59. <a href=""><img src="images/nav/nav4.png" alt="" /></a>
  60. <a href="">分类</a>
  61. </li>
  62. </ul>
  63. </header>
  64. <!-- 主体 -->
  65. <main style="height: 100px;">
  66. <div class="top"> gggggggggggggggggggggggggggggfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
  67. </div>
  68. </main>
  69. <!-- 页脚 -->
  70. <footer>
  71. <div class="item active">
  72. <a href="" class="iconfont icon-shejiaotubiao-44"></a>
  73. </div>
  74. <div class="item">
  75. <a href="" class="iconfont icon-gouwuche"></a>
  76. <a href="">购物车</a>
  77. </div>
  78. <div class="item">
  79. <a href="" class="iconfont icon-wodetaobao"></a>
  80. <a href="">我的淘宝</a>
  81. </div>
  82. </footer>

CSS部分

  1. /* 样式重置 */
  2. * {
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 链接 */
  8. a {
  9. text-decoration: none;
  10. color: #555;
  11. }
  12. /* 列表 */
  13. li {
  14. list-style: none;
  15. }
  16. :root {
  17. font-size: calc(100vw / 3.75);
  18. }
  19. body {
  20. font-size: 0.12rem;
  21. color: #333;
  22. max-width: 750px;
  23. min-width: 320px;
  24. margin: auto;
  25. background-color: #f4f4f4;
  26. }
  27. @media screen and (max-width: 320px) {
  28. :root {
  29. font-size: 85px;
  30. }
  31. }
  32. @media screen and (min-width: 640px) {
  33. :root {
  34. font-size: 170px;
  35. }
  36. }
  37. header {
  38. position: relative;
  39. }
  40. header .top {
  41. width: 100vw;
  42. background-color: coral;
  43. position: fixed;
  44. top: 0;
  45. left: 0;
  46. right: 0;
  47. display: grid;
  48. grid-template-columns: 0.35rem 1fr;
  49. padding: 0.05rem;
  50. /* 调整显示层级 */
  51. z-index: 99;
  52. }
  53. header .top .logo {
  54. color: white;
  55. font-size: 0.25rem;
  56. }
  57. header .top .search {
  58. background-color: orangered;
  59. color: #eee;
  60. display: grid;
  61. place-content: center;
  62. border-radius: 0.05rem;
  63. font-size: small;
  64. }
  65. /* 轮播图,用图片代替 */
  66. header .slider {
  67. height: 1.25rem;
  68. position: absolute;
  69. top: 0.35rem;
  70. }
  71. header .slider img,
  72. header .nav img {
  73. width: 100%;
  74. height: 100%;
  75. }
  76. /* 导航组 */
  77. header .nav {
  78. background-color: #fff;
  79. position: absolute;
  80. top: calc(0.35rem + 1.25rem);
  81. display: grid;
  82. grid-template-columns: repeat(5, 1fr);
  83. font-size: 0.11rem;
  84. padding: 0.2rem 0.1rem;
  85. }
  86. header .nav .item {
  87. display: grid;
  88. place-items: center;
  89. padding: 0 0.05rem;
  90. }
  91. header .nav .item a {
  92. padding: 0 0.05rem;
  93. }
  94. footer {
  95. width: 100vw;
  96. height: 0.46rem;
  97. background-color: #fff;
  98. position: fixed;
  99. bottom: 0;
  100. left: 0;
  101. right: 0;
  102. display: grid;
  103. grid-template-columns: repeat(3, 1fr);
  104. place-items: center;
  105. }
  106. footer .item {
  107. display: grid;
  108. place-items: center;
  109. }
  110. footer .item .iconfont {
  111. font-size: 0.2rem;
  112. }
  113. footer .item.active .iconfont {
  114. font-size: 0.36rem;
  115. color: coral;
  116. }

效果示例图

效果示例

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