Blogger Information
Blog 11
fans 0
comment 0
visits 8082
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Gird网格布局实现商品列表页--PHP培训十期线上班
宋明杰
Original
699 people have browsed it

Gird网格布局实现商品列表页

初步接触Grid,对他的属性和参数很不熟练,东拉西扯,东拼西凑,总算完成了表面工作,但代码惨不忍睹,特别是CSS部分,

对GRID容器和属性的边框—内外边距,还没掌握怎样设置

HTML代码

  1. <body>
  2. <div class="essp">
  3. <div class="essp-bt">
  4. <span>二手商品</span>
  5. </div>
  6. <div class="essp-xq">
  7. <div class="essp-xq1">
  8. <a href="#">抢好货</a>
  9. <span>0低价,便捷,安全,快速</span>
  10. </div>
  11. <div class="essp-xq2">
  12. <span>热门分类</span>
  13. <a href="#">美女写真</a>
  14. <a href="#">日本美女</a>
  15. <a href="#">中国美女</a>
  16. <a href="#">美国美女</a>
  17. <a href="#">AV美女</a>
  18. </div>
  19. <div class="essp-xq3">
  20. <div class="essp-xq3a">
  21. <div class="essp-xq3a1">
  22. <a href="#"><img src="img/999.jpg"></a>
  23. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  24. <div class="essp-xq3a2">
  25. <i>¥999</i>
  26. <b>美女</b>
  27. </div>
  28. </div>
  29. <div class="essp-xq3a1">
  30. <a href="#"><img src="img/999.jpg"></a>
  31. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  32. <div class="essp-xq3a2">
  33. <i>¥999</i>
  34. <b>美女</b>
  35. </div>
  36. </div>
  37. <div class="essp-xq3a1">
  38. <a href="#"><img src="img/999.jpg"></a>
  39. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  40. <div class="essp-xq3a2">
  41. <i>¥999</i>
  42. <b>美女</b>
  43. </div>
  44. </div>
  45. <div class="essp-xq3a1">
  46. <a href="#"><img src="img/999.jpg"></a>
  47. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  48. <div class="essp-xq3a2">
  49. <i>¥999</i>
  50. <b>美女</b>
  51. </div>
  52. </div>
  53. <div class="essp-xq3a1">
  54. <a href="#"><img src="img/999.jpg"></a>
  55. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  56. <div class="essp-xq3a2">
  57. <i>¥999</i>
  58. <b>美女</b>
  59. </div>
  60. </div>
  61. <div class="essp-xq3a1">
  62. <a href="#"><img src="img/999.jpg"></a>
  63. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  64. <div class="essp-xq3a2">
  65. <i>¥999</i>
  66. <b>美女</b>
  67. </div>
  68. </div>
  69. <div class="essp-xq3a1">
  70. <a href="#"><img src="img/999.jpg"></a>
  71. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  72. <div class="essp-xq3a2">
  73. <i>¥999</i>
  74. <b>美女</b>
  75. </div>
  76. </div>
  77. <div class="essp-xq3a1">
  78. <a href="#"><img src="img/999.jpg"></a>
  79. <a href="">解决实际的假发来得及反倒是浪费绝对是是好</a>
  80. <div class="essp-xq3a2">
  81. <i>¥999</i>
  82. <b>美女</b>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="essp-xq3b">
  87. <a href="#"><img src="img/1.png"> </a>
  88. <a href="#"><img src="img/2.png"> </a>
  89. <a href="#"><img src="img/3.png"> </a>
  90. <a href="#"><img src="img/4.png"> </a>
  91. <!-- <a href="#" class="er1"><img src="img/ad1.png" class="er1"> </a>-->
  92. <span class="er1"><img src="img/ad1.png"></span>
  93. <span class="er1"><img src="img/ad2.jpg"></span>
  94. <!-- <span>2</span>--
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. </body>

CSS代码:

  1. *{
  2. margin: 0px;
  3. padding: 0px;
  4. /*background: #cccccc;*/
  5. /*font-size:13px;*/
  6. /*color: #333333;*/
  7. /*border: 1px solid red;*/
  8. }
  9. a{
  10. text-decoration: none;
  11. }
  12. body{
  13. background: #cccccc;
  14. }
  15. .essp{
  16. width: 1200px;
  17. margin: auto;
  18. background: #ffffff;
  19. }
  20. .essp>.essp-bt{
  21. padding: 20px;
  22. text-align: center;
  23. background: #cccccc;
  24. }
  25. .essp>.essp-bt span{
  26. font-size: 30px;
  27. color: #333;
  28. border-bottom: 5px solid red;
  29. }
  30. .essp>.essp-xq>.essp-xq1{
  31. margin: 10px 10px;
  32. border-bottom: 1px solid #cccccc;
  33. /*background: #ffffff;*/
  34. /*color: #333333;*/
  35. /*font-size: 25px;*/
  36. display: flex;
  37. padding: 8px;
  38. }
  39. .essp>.essp-xq>.essp-xq1>a{
  40. font-size: 20px;
  41. color: #333333;
  42. font-weight: bold;
  43. }
  44. .essp>.essp-xq>.essp-xq1>span{
  45. font-size: 13px;
  46. color: red;
  47. margin-left: 20px;
  48. align-self:flex-end;
  49. }
  50. .essp>.essp-xq>.essp-xq2{
  51. margin-bottom: 8px;
  52. margin-left: 15px;
  53. }
  54. .essp>.essp-xq>.essp-xq2>span{
  55. font-size: 20px;
  56. color: red;
  57. /*margin-bottom: 10px;*/
  58. }
  59. .essp>.essp-xq>.essp-xq2>a{
  60. font-size: 13px;
  61. color: #333333;
  62. margin: 15px;
  63. }
  64. .essp>.essp-xq>.essp-xq3{
  65. /*width: 1200px;*/
  66. /*height: 480px;*/
  67. display: grid;
  68. grid-template-columns: 780px 380px;
  69. grid-template-rows: 460px;
  70. grid-gap:10px;
  71. justify-content: center;
  72. }
  73. .essp>.essp-xq>.essp-xq3>.essp-xq3a{
  74. display: grid;
  75. grid-template-columns: repeat(4,185px);
  76. grid-template-rows: 220px;
  77. justify-content: center;
  78. grid-gap: 12px;
  79. /*justify-content: center;*/
  80. /*align-items: center;*/
  81. }
  82. .essp>.essp-xq>.essp-xq3>.essp-xq3a>.essp-xq3a1{
  83. display: grid;
  84. grid-template-columns: 100%;
  85. grid-template-rows: 60% 20% 10%;
  86. grid-gap: 5%;
  87. }
  88. .essp>.essp-xq>.essp-xq3>.essp-xq3a>.essp-xq3a1 img,
  89. .essp>.essp-xq>.essp-xq3>.essp-xq3b img{
  90. width: 100%;
  91. height: 100%;
  92. border-radius: 5px;
  93. }
  94. .essp>.essp-xq>.essp-xq3>.essp-xq3a>.essp-xq3a1 a{
  95. color: #333333;
  96. font-size: 13px;
  97. }
  98. .essp>.essp-xq>.essp-xq3>.essp-xq3a>.essp-xq3a1>.essp-xq3a2{
  99. display: grid;
  100. grid-template-columns: 50% 50%;
  101. grid-template-rows: 100%;
  102. /*justify-content: space-between;*/
  103. }
  104. .essp>.essp-xq>.essp-xq3>.essp-xq3a>.essp-xq3a1>.essp-xq3a2 i{
  105. color: red;
  106. font-size: 13px;
  107. }
  108. .essp>.essp-xq>.essp-xq3>.essp-xq3a>.essp-xq3a1>.essp-xq3a2 b{
  109. margin-left: auto;
  110. background: #0077aa;
  111. color: #e9e9e9;
  112. font-size: 13px;
  113. border-radius: 3px;
  114. }
  115. .essp>.essp-xq>.essp-xq3>.essp-xq3b{
  116. display: grid;
  117. grid-template-columns: 46% 46%;
  118. grid-template-rows: 30% 30% 15% 15%;
  119. grid-gap: 3%;
  120. justify-content: center;
  121. /*grid-template-areas: '1 2'*/
  122. /* '3 4'*/
  123. /* '5 5'*/
  124. /* '6 6';*/
  125. }
  126. .essp>.essp-xq>.essp-xq3>.essp-xq3b>.er1{
  127. grid-column-start: span 2;
  128. }
  129. .essp>.essp-xq>.essp-xq3>.essp-xq3b>.er2{
  130. grid-column-start: span 2;
  131. }

运行截图

手写作业

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:字写得好看的人, 学习能力肯定不会差的... 相信自己, 一定可以掌握grid
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