博客列表 >grid布局仿照php中文网的一个模块

grid布局仿照php中文网的一个模块

努力努力再努力
努力努力再努力原创
2020年06月30日 17:12:12681浏览
仿照的结果图

仿照的代码为
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Document</title>
  7. <style>
  8. * {
  9. margin: 0px;
  10. padding: 0px;
  11. box-sizing: border-box;
  12. }
  13. .course {
  14. width: 1200px;
  15. height: 647px;
  16. margin: 10px auto;
  17. }
  18. /* 设置标题 */
  19. .course > .course-title {
  20. font-size: 1.2rem;
  21. width: 1185px;
  22. line-height: 30px;
  23. text-align: center;
  24. margin: 20px;
  25. }
  26. /* 设置gride布局 已将设置宽度了 直接设置高度即可*/
  27. .course > .contariner {
  28. height: 567px;
  29. display: grid;
  30. grid-template-columns: repeat(5, 1fr);
  31. grid-template-rows: repeat(3, 1fr);
  32. }
  33. /* 设置每个的项目在单元格的位置以及大小 */
  34. .course > .contariner > .course-list {
  35. width: 217px;
  36. height: 172px;
  37. box-shadow: 0 0 10px #555;
  38. /* 设置项目垂直居上 水平居中 */
  39. place-self: start center;
  40. border-radius: 5%;
  41. position: relative;
  42. /* 隐藏p标签描述的文字超出问题 */
  43. overflow: hidden;
  44. }
  45. .course > .contariner > .course-list:first-of-type {
  46. grid-row: span 2;
  47. height: 364px;
  48. }
  49. .course > .contariner > .course-list img {
  50. /* 圆角 */
  51. width: 100%;
  52. border-radius: 5%;
  53. }
  54. /* 去掉下划线 */
  55. .course > .contariner > .course-list > a {
  56. text-decoration: none;
  57. cursor: pointer;
  58. }
  59. /* 设置播放量 添加背景是为了隐藏与播放次数之间的文字*/
  60. .course > .contariner > .course-list .num {
  61. position: absolute;
  62. width: 100%;
  63. height: 42px;
  64. padding: 0 20px;
  65. bottom: 0px;
  66. color: #93999f;
  67. font-size: 12px;
  68. line-height: 36px;
  69. background-color: #fff;
  70. border-radius: 8px;
  71. }
  72. /* 设置图片标题 */
  73. .course > .contariner > .course-list .desc {
  74. height: 40px;
  75. font-size: 12px;
  76. color: #656;
  77. line-height: 21px;
  78. padding: 16px 17px 6px;
  79. position: relative;
  80. top: -35px;
  81. border-radius: 8px;
  82. background-color: #fff;
  83. }
  84. /* 设置过度 */
  85. .course > .contariner > .course-list > a > .desc:hover {
  86. height: 130px;
  87. margin-top: -60px;
  88. transition: 0.5s;
  89. }
  90. .course > .contariner > .course-list .desc span {
  91. padding: 2px;
  92. margin-right: 4px;
  93. margin-top: 2px;
  94. font-size: 12px;
  95. color: #fff;
  96. line-height: 12px;
  97. border-radius: 1px;
  98. background-color: #93999f;
  99. }
  100. .course > .contariner > .course-list .desc p {
  101. margin-top: 5px;
  102. }
  103. </style>
  104. </head>
  105. <body>
  106. <div class="course">
  107. <div class="course-title">php入门精品课程</div>
  108. <div class="contariner">
  109. <div class="course-list"><img src="./images/1.jpg" alt="" /></div>
  110. <div class="course-list">
  111. <a href="">
  112. <img src="./images/2.jpg" alt="" />
  113. <div class="desc">
  114. <h3><span>初级</span>编程学习方法分享直播公益课</h3>
  115. </div>
  116. <div class="num">1w+次播放</div>
  117. </a>
  118. </div>
  119. <div class="course-list">
  120. <a href="">
  121. <img src="./images/3.jpg" alt="" />
  122. <div class="desc">
  123. <h3><span>初级</span>编程学习方法分享直播公益课</h3>
  124. </div>
  125. <div class="num">18w+次播放</div>
  126. </a>
  127. </div>
  128. <div class="course-list">
  129. <a href="">
  130. <img src="./images/4.jpg" alt="" />
  131. <div class="desc">
  132. <h3><span>初级</span>CSS视频教程-玉女心经版</h3>
  133. <p>
  134. 本章节讲解的是有关CSS基础的内容,轻松明快,适合新手观看学习。
  135. </p>
  136. </div>
  137. <div class="num">10w+次播放</div>
  138. </a>
  139. </div>
  140. <div class="course-list">
  141. <a href="">
  142. <img src="./images/5.jpg" alt="" />
  143. <div class="desc">
  144. <h3><span>初级</span>JavaScript极速入门_玉女心经系列</h3>
  145. </div>
  146. <div class="num">18w+次播放</div>
  147. </a>
  148. </div>
  149. <div class="course-list">
  150. <a href="">
  151. <img src="./images/6.jpg" alt="" />
  152. <div class="desc">
  153. <h3><span>中级</span>独孤九贱(6)_jQuery视频教程</h3>
  154. </div>
  155. <div class="num">12w+次播放</div>
  156. </a>
  157. </div>
  158. <div class="course-list">
  159. <a href="">
  160. <img src="./images/7.jpg" alt="" />
  161. <div class="desc">
  162. <h3><span>初级</span>30分钟学会网站布局</h3>
  163. </div>
  164. <div class="num">6w+次播放</div>
  165. </a>
  166. </div>
  167. <div class="course-list">
  168. <a href="">
  169. <img src="./images/8.jpg" alt="" />
  170. <div class="desc">
  171. <h3><span>初级</span>[公益直播]Web前端开发极速入门</h3>
  172. </div>
  173. <div class="num">5w+次播放</div>
  174. </a>
  175. </div>
  176. <div class="course-list">
  177. <a href="">
  178. <img src="./images/9.jpg" alt="" />
  179. <div class="desc">
  180. <h3><span>初级</span>phpStudy极速入门视频教程</h3>
  181. </div>
  182. <div class="num">40w+次播放</div>
  183. </a>
  184. </div>
  185. <div class="course-list">
  186. <a href="">
  187. <img src="./images/10.jpg" alt="" />
  188. <div class="desc">
  189. <h3><span>中级</span>ThinkPHP6.0极速入门(视频教程)</h3>
  190. </div>
  191. <div class="num">4w+次播放</div>
  192. </a>
  193. </div>
  194. <div class="course-list">
  195. <a href="">
  196. <img src="./images/11.jpg" alt="" />
  197. <div class="desc">
  198. <h3><span>中级</span>独孤九贱(4)_PHP视频教程</h3>
  199. </div>
  200. <div class="num">40w+次播放</div>
  201. </a>
  202. </div>
  203. <div class="course-list">
  204. <a href="">
  205. <img src="./images/12.jpg" alt="" />
  206. <div class="desc">
  207. <h3><span>初级</span>php完全自学手册</h3>
  208. </div>
  209. <div class="num">20w+次播放</div>
  210. </a>
  211. </div>
  212. <div class="course-list">
  213. <a href="">
  214. <img src="./images/13.jpg" alt="" />
  215. <div class="desc">
  216. <h3><span>初级</span>MySQL权威开发指南(教程)</h3>
  217. </div>
  218. <div class="num">2w+次播放</div>
  219. </a>
  220. </div>
  221. <div class="course-list">
  222. <a href="">
  223. <img src="./images/14.jpg" alt="" />
  224. <div class="desc">
  225. <h3><span>中级</span>[公益直播]PHP实战开发极速入门</h3>
  226. </div>
  227. <div class="num">3w+次播放</div>
  228. </a>
  229. </div>
  230. </div>
  231. </div>
  232. </body>
  233. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议