博客列表 >移动端布局的基本思路与三种视口之间的关系、实战手机页面的基本整体架构:页眉,页脚,主体等

移动端布局的基本思路与三种视口之间的关系、实战手机页面的基本整体架构:页眉,页脚,主体等

Blackeye
Blackeye原创
2022年03月31日 13:30:38555浏览

总结出移动端布局的基本思路与三种视口之间的关系?

  1. 移动端布局需要根据设计师的方案计算出合理的font-size
  2. 利用rem进行理想视口(支持移动端额视口开发)。
  3. html中设置meta属性令width=device-width来保证布局视口和视觉视口的宽度统一,利用initial-scale=1.0保证初始化缩放比例一致

hwshow

  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. <title>taobao</title>
  8. <link rel="stylesheet" href="static/css/reset.css" />
  9. <link rel="stylesheet" href="static/css/header.css" />
  10. <link rel="stylesheet" href="static/css/footer.css" />
  11. <link rel="stylesheet" href="static/css/main.css">
  12. <link rel="stylesheet" href="static/font_icon/iconfont.css" />
  13. </head>
  14. <body>
  15. <!-- 头部 -->
  16. <header>
  17. <div class="top">
  18. <div class="iconfont icon-shejiaotubiao-08 logo"></div>
  19. <div class="search">
  20. <a href="#" class="iconfont icon-fangdajing text">寻找宝贝店铺</a>
  21. </div>
  22. </div>
  23. <div class="slider">
  24. <img src="static/images/banner/banner4.jpg" alt="" />
  25. </div>
  26. <div class="nav">
  27. <div class="navlist">
  28. <a href="#">
  29. <img src="static/images/nav/nav1.png" alt="" />
  30. <span>天猫新品</span>
  31. </a>
  32. </div>
  33. <div class="navlist">
  34. <a href="#">
  35. <img src="static/images/nav/nav2.png" alt="" /><span
  36. >今日爆款</span
  37. ></a
  38. >
  39. </div>
  40. <div class="navlist">
  41. <a href="#"
  42. ><img src="static/images/nav/nav3.png" alt="" /><span
  43. >天猫国际</span
  44. ></a
  45. >
  46. </div>
  47. <div class="navlist">
  48. <a href="#"
  49. ><img src="static/images/nav/nav4.png" alt="" /><span
  50. >天猫超市</span
  51. ></a
  52. >
  53. </div>
  54. <div class="navlist">
  55. <a href="#"
  56. ><img src="static/images/nav/nav5.png" alt="" /><span
  57. >充值中心</span
  58. ></a
  59. >
  60. </div>
  61. <div class="navlist">
  62. <a href="#"
  63. ><img src="static/images/nav/nav6.png" alt="" /><span
  64. >机票酒店</span
  65. ></a
  66. >
  67. </div>
  68. <div class="navlist">
  69. <a href="#"
  70. ><img src="static/images/nav/nav7.png" alt="" /><span
  71. >金币庄园</span
  72. ></a
  73. >
  74. </div>
  75. <div class="navlist">
  76. <a href="#"
  77. ><img src="static/images/nav/nav8.png" alt="" /><span
  78. >阿里拍卖</span
  79. ></a
  80. >
  81. </div>
  82. <div class="navlist">
  83. <a href="#"
  84. ><img src="static/images/nav/nav1.png" alt="" /><span
  85. >淘宝吃货</span
  86. ></a
  87. >
  88. </div>
  89. <div class="navlist">
  90. <a href="#"
  91. ><img src="static/images/nav/nav2.png" alt="" /><span
  92. >分类</span
  93. ></a
  94. >
  95. </div>
  96. <div class="roll"></div>
  97. </div>
  98. </header>
  99. <!-- 主体 -->
  100. <main>
  101. <div class="topMain">
  102. <div class="topMain-left">
  103. </div>
  104. <div class="topMain-right">
  105. </div>
  106. </div>
  107. <div class="displayMain">
  108. <div class="advance">
  109. </div>
  110. <div class="displayWindow">
  111. </div>
  112. </div>
  113. </main>
  114. <!-- 底部 -->
  115. <footer>
  116. <div class="buttom">
  117. <div class="buttomnav">
  118. <a href="#" class="iconfont icon-shejiaotubiao-44"></a>
  119. </div>
  120. <div class="buttomnav">
  121. <a href="#" class="iconfont icon-gouwuche"></a>
  122. <span>购物车</span>
  123. </div>
  124. <div class="buttomnav">
  125. <a href="#" class="iconfont icon-wodetaobao"></a>
  126. <span>我的淘宝</span>
  127. </div>
  128. </div>
  129. </footer>
  130. </body>
  131. </html>
  1. *{
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. a{
  7. text-decoration: none;
  8. color: black;
  9. }
  10. li{
  11. list-style: none;
  12. }
  13. :root{
  14. font-size: calc(100vw / 3.75);
  15. }
  16. body{
  17. font-size: .12rem;
  18. color: #333;
  19. max-width: 7.5rem;
  20. min-width: 3.2rem;
  21. margin: auto;
  22. background-color: #f4f4f4;
  23. }
  24. @media screen and (max-width: 320px) {
  25. :root {
  26. font-size: 85px;
  27. }
  28. }
  29. @media screen and (min-width: 640px) {
  30. :root {
  31. font-size: 170px;
  32. }
  33. }
  1. header{
  2. position: relative;
  3. }
  4. header .top{
  5. position: fixed;
  6. width: 100vw;
  7. top: 0;
  8. right: 0;
  9. left: 0;
  10. background-color: rgb(255, 133, 42);
  11. z-index: 99;
  12. display: grid;
  13. grid-template-columns: .37rem 1fr;
  14. }
  15. header .top .logo{
  16. font-size: 0.3rem;
  17. color: white;
  18. padding-left: .05rem;
  19. place-self: end;
  20. }
  21. header .top .search{
  22. display: grid;
  23. grid-template-columns: .05rem 1fr .05rem;
  24. grid-template-rows: .05rem 1fr .05rem;
  25. }
  26. header .top .search a{
  27. background-color: rgb(255, 78, 34);
  28. border-radius: .05rem;
  29. color: rgb(240, 224, 220);
  30. font-size: 0.13rem;
  31. grid-area: 2 / 2 / span 1 / span 1;
  32. text-align: center;
  33. }
  34. header .slider{
  35. height: 1.2rem;
  36. position: absolute;
  37. top: .30rem;
  38. }
  39. header .slider img,
  40. header .nav img{
  41. width: 100%;
  42. height: 100%;
  43. }
  44. header .nav{
  45. position: absolute;
  46. top:1.5rem;
  47. width: 100vw;
  48. height: 1.76rem;
  49. padding-top: .1rem;
  50. display: grid;
  51. grid-template-columns: repeat(5,.61rem);
  52. grid-template-rows: 1fr 1fr .2rem;
  53. background-color: white;
  54. place-content: space-around;
  55. }
  56. header .nav img{
  57. width: .61rem;
  58. height: .48rem;
  59. }
  60. header .nav .roll{
  61. grid-area: 3 / 1 / span 1 / span 5;
  62. place-self: center;
  63. width: .5rem;
  64. height: .03rem;
  65. background-color: rgb(212,216,222);
  66. border-radius: 4px;
  67. }
  68. header .nav .navlist{
  69. text-align: center;
  70. }
  1. footer {
  2. position: fixed;
  3. width: 100vw;
  4. height: .46rem;
  5. bottom: 0;
  6. right: 0;
  7. left: 0;
  8. background-color: rgb(255, 255, 255);
  9. }
  10. footer .buttom{
  11. display: grid;
  12. grid-template-columns: repeat(3,1fr);
  13. grid-template-rows: 0.05rem 0.36rem 0.05rem;
  14. place-items: space-around;
  15. }
  16. /* 36*36 20*20 */
  17. footer .buttom .buttomnav{
  18. grid-row: 2 / 3;
  19. height: .36rem;
  20. text-align: center;
  21. }
  22. footer .buttom .buttomnav a~span{
  23. display:block;
  24. font-size: 0.12rem;
  25. }
  26. footer .buttom .buttomnav:first-of-type a{
  27. font-size: 0.33rem;
  28. color: coral;
  29. }
  30. footer .buttom .buttomnav:nth-of-type(n+2) a{
  31. font-size: 0.2rem;
  32. }
  1. main .topMain{
  2. position: absolute;
  3. top: 3.36rem;
  4. width: 100vw;
  5. height: 4.03rem;
  6. background-color: #fff;
  7. border-radius: 0.06rem;
  8. }
  9. main .topMain{
  10. display: grid;
  11. margin-right: 2rem;
  12. }
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议