博客列表 >CSS基础Grid布局公共二手交易区组件-PHP培训十期线上班 学号:510251 12月28日作业

CSS基础Grid布局公共二手交易区组件-PHP培训十期线上班 学号:510251 12月28日作业

赵大叔
赵大叔原创
2020年01月02日 11:03:57755浏览

Grid布局公共二手交易区组件

布局思路

1.1 整体划为一个四行二列网格:

大标题 大标题:第1行全部
标题1 标题1:第2行全部
标题2 标题2:第3行全部
商品展示 快速入口:商品展示,第4行,第1列。快速入口,第4行,第2列

1.2 商品展示:第4行,第1列,再次划分为两行四列网格

1.3 快速入口:第4行,第2列,再次划分为四行两列网格

HTML代码和CSS样式

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Grid布局公共二手交易区组件</title>
  6. <!-- 初始化样式-->
  7. <link rel="stylesheet" href="public_reset.css">
  8. <!-- 大标题样式-->
  9. <link rel="stylesheet" href="public_headerline.css">
  10. <style>
  11. /*网格布局*/
  12. body * {
  13. /*outline: 1px dashed red;*/
  14. }
  15. body {
  16. width: 1200px;
  17. display: grid;
  18. /*padding: 10px;*/
  19. margin: auto;
  20. box-sizing: border-box;
  21. /*打格子,四行二列*/
  22. grid-template-columns: 760px 440px;
  23. grid-template-rows: 92px 32px 60px 440px;
  24. /*grid-gap: 5px;*/
  25. }
  26. body {
  27. /*网格区域命名*/
  28. grid-template-areas:
  29. 'headerline headerline'
  30. 'title1 title1'
  31. 'title2 title2'
  32. 'goods-list quick-entry';
  33. }
  34. .public-headerline {
  35. /*大标题命名*/
  36. grid-area: headerline;
  37. }
  38. .title1 {
  39. grid-area: title1;
  40. /*标题1下边线*/
  41. border-bottom: 1px solid #ccc;
  42. }
  43. .title1 > a{
  44. font-size: 23px;
  45. margin-right: 20px;
  46. }
  47. .title1 > span{
  48. color:red;
  49. }
  50. .title2 {
  51. grid-area: title2;
  52. }
  53. .title2 > span{
  54. color:red;
  55. font-size: 23px;
  56. }
  57. .title2 > a{
  58. padding-left:20px;;
  59. }
  60. .goods-list {
  61. grid-area: goods-list;
  62. display: grid;
  63. /*再将goods-list划分为两行四列网格*/
  64. grid-template-columns: repeat(4,178px);
  65. grid-template-rows: repeat(2,200px);
  66. /*行间距15px,列间距10px*/
  67. grid-gap: 15px 10px;
  68. }
  69. .goods-list img{
  70. border-radius: 5px;
  71. border: 1px solid #ccc;
  72. display: block;
  73. }
  74. .goods-list a{
  75. display: block;
  76. margin-bottom: 13px;
  77. }
  78. .goods-list img:hover{
  79. box-shadow: 0 0 8px #ccc;
  80. }
  81. .goods-list > .intro > div{
  82. display: flex;
  83. /*价格文字两端对齐*/
  84. justify-content: space-between;
  85. }
  86. .goods-list > .intro > div > span:first-of-type{
  87. color:red;
  88. }
  89. .goods-list > .intro > div > span:last-of-type{
  90. background: #55a532;
  91. color: white;
  92. padding: 0 3px;
  93. }
  94. .quick-entry {
  95. grid-area: quick-entry;
  96. display: grid;
  97. /*再将quick-entry划分为四行两列网格*/
  98. grid-template-columns: repeat(2,190px);
  99. grid-template-rows: 130px 130px 60px 60px;
  100. /*行间距12px,列间距25px*/
  101. grid-gap: 12px 25px;
  102. /*网格区域命名*/
  103. grid-template-areas:
  104. 'img1 img2'
  105. 'img3 img4'
  106. 'img5 img5'
  107. 'img6 img6';
  108. }
  109. .quick-entry a:nth-of-type(5){
  110. grid-area: img5;
  111. }
  112. .quick-entry a:last-of-type{
  113. grid-area: img6;
  114. }
  115. </style>
  116. </head>
  117. <body>
  118. <!--大标题-->
  119. <div class="public-headerline">
  120. <span>二手交易</span>
  121. </div>
  122. <div class="title1">
  123. <a href="">抢好货</a>
  124. <span>0低价,便捷,安全,快速</span>
  125. </div>
  126. <div class="title2">
  127. <span>热门分类</span>
  128. <a href="">美女写真</a>
  129. <a href="">日本美女</a>
  130. <a href="">美国美女</a>
  131. <a href="">国内美女</a>
  132. <a href="">AV美女</a>
  133. </div>
  134. <div class="goods-list">
  135. <!-- 商品简介-->
  136. <div class="intro">
  137. <a href=""><img src="../static/images/shop/shop1.jpg" alt="" width="176" height="120"></a>
  138. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  139. <div>
  140. <span>&yen; 333</span>
  141. <span>美女</span>
  142. </div>
  143. </div>
  144. <div class="intro">
  145. <a href=""><img src="../static/images/shop/shop2.jpg" alt="" width="176" height="120"></a>
  146. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  147. <div>
  148. <span>&yen; 333</span>
  149. <span>美女</span>
  150. </div>
  151. </div>
  152. <div class="intro">
  153. <a href=""><img src="../static/images/shop/shop3.jpg" alt="" width="176" height="120"></a>
  154. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  155. <div>
  156. <span>&yen; 333</span>
  157. <span>美女</span>
  158. </div>
  159. </div>
  160. <div class="intro">
  161. <a href=""><img src="../static/images/shop/shop4.jpg" alt="" width="176" height="120"></a>
  162. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  163. <div>
  164. <span>&yen; 333</span>
  165. <span>美女</span>
  166. </div>
  167. </div>
  168. <div class="intro">
  169. <a href=""><img src="../static/images/shop/shop5.jpg" alt="" width="176" height="120"></a>
  170. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  171. <div>
  172. <span>&yen; 333</span>
  173. <span>美女</span>
  174. </div>
  175. </div>
  176. <div class="intro">
  177. <a href=""><img src="../static/images/shop/shop6.jpg" alt="" width="176" height="120"></a>
  178. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  179. <div>
  180. <span>&yen; 333</span>
  181. <span>美女</span>
  182. </div>
  183. </div>
  184. <div class="intro">
  185. <a href=""><img src="../static/images/shop/shop7.jpg" alt="" width="176" height="120"></a>
  186. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  187. <div>
  188. <span>&yen; 333</span>
  189. <span>美女</span>
  190. </div>
  191. </div>
  192. <div class="intro">
  193. <a href=""><img src="../static/images/shop/shop8.jpg" alt="" width="176" height="120"></a>
  194. <a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
  195. <div>
  196. <span>&yen; 333</span>
  197. <span>美女</span>
  198. </div>
  199. </div>
  200. </div>
  201. <div class="quick-entry">
  202. <a href=""><img src="../static/images/ad/1.png" alt=""></a>
  203. <a href=""><img src="../static/images/ad/1.png" alt=""></a>
  204. <a href=""><img src="../static/images/ad/1.png" alt=""></a>
  205. <a href=""><img src="../static/images/ad/1.png" alt=""></a>
  206. <a href=""><img src="../static/images/ad/image.png" alt=""></a>
  207. <a href=""><img src="../static/images/ad/ad2.jpg" alt=""></a>
  208. </div>
  209. </body>
  210. </html>

效果图

手抄Grid布局基础知识


声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议