ASCII码 ASCII码

css-移动端布局-pxtorem与淘宝移动端实战

发布于:2022-03-31 11:17:55  栏目:技术文档

作业内容:

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

1、移动端布局

1、通过设置viewport缩放来实现2、通过rem相对单位来实现DPR、rem都用到缩放因子来解决问题

2、rem与px详解

step1比较

step2查看

step3异常

step4优化

step5检查

实战作业

  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. html {
  13. font-size: calc(100vw / 3.75);
  14. }
  15. body {
  16. font-size: 0.12rem;
  17. background-color:#f4f4f4;
  18. display: grid;
  19. /* grid-template-rows: repeat(3,1fr); */
  20. }
  21. header{
  22. display: grid;
  23. }
  24. header .head{
  25. display: grid;
  26. grid-template-columns: .4rem 1fr;
  27. place-items: center;
  28. width: 100vw;
  29. background-color: tomato;
  30. position: fixed;
  31. top: 0;
  32. left: 0;
  33. }
  34. header .head .tb{
  35. margin: .05rem;
  36. margin-left: .1rem;
  37. font-size: .28rem;
  38. color: white;
  39. }
  40. header .placeholder{
  41. background-color: white;
  42. width: 3.2rem;
  43. height: .25rem;
  44. border-radius: .05rem;
  45. border: none;
  46. text-align: center;
  47. }
  48. header .img1{
  49. width: 100%;
  50. height: 100%;
  51. grid-column: span 2;
  52. margin-top: .37rem;
  53. }
  54. header .navs{
  55. background-color: white;
  56. grid-column: span 2;
  57. display: grid;
  58. grid-template-columns: repeat(5,1fr);
  59. place-items: center;
  60. padding: .1rem;
  61. }
  62. header .navs .nav{
  63. text-align: center;
  64. padding: .05rem;
  65. font-size: .1rem;
  66. }
  67. header .navs .nav img{
  68. width: 100%;
  69. }
  70. main{
  71. background-color: white;
  72. border-radius: .1rem;
  73. margin: .1rem;
  74. padding: .1rem;
  75. }
  76. main .list1{
  77. display: grid;
  78. grid-template-columns: repeat(4,1fr);
  79. }
  80. main .list1 .box{
  81. display: grid;
  82. padding: .05rem;
  83. }
  84. main .list1 .box .desc1{
  85. font-size: .16rem;
  86. font-weight: bolder;
  87. }
  88. main .list1 .box .desc2{
  89. font-weight: bold;
  90. font-size: .14rem;
  91. color: rgb(197, 73, 36);
  92. }
  93. main .list1 .box .content{
  94. padding: .05rem;
  95. border-radius: .1rem;
  96. display: grid;
  97. background-color: rgb(253, 242, 239);
  98. }
  99. main .list1 .box div img{
  100. width: 100%;
  101. }
相关推荐
阅读 +