博客列表 >"热门推荐"课程列表组件(Grid)

"热门推荐"课程列表组件(Grid)

PHP中文网用户-6406556
PHP中文网用户-6406556原创
2023年03月27日 16:29:16234浏览

代码展示

html

  1. <div class="course">
  2. <div class="biaoti">
  3. <h2>热门推荐</h2>
  4. <span class="gengduo">更多</span>
  5. </div>
  6. <div class="courses-list">
  7. <!-- 课程 -->
  8. <div class="list">
  9. <!-- 课程图片 -->
  10. <a href="">
  11. <img src="111.jpg" alt="" />
  12. </a>
  13. <!-- 课程描述 -->
  14. <div class="desc">
  15. <div class="title">
  16. <small class="tag">中级</small>
  17. <a href="">Golang深入理解GPM模型</a>
  18. </div>
  19. <div class="other">
  20. <span>600次学习</span>
  21. <span><span class="iconfont icon-shoucang"></span>收藏</span>
  22. </div>
  23. </div>
  24. </div>
  25. </div>

css

  1. body {
  2. background-color: #efefef;
  3. }
  4. body a {
  5. text-decoration: none;
  6. color: #555;
  7. font-size: small;
  8. }
  9. body a:hover {
  10. color: red;
  11. }
  12. .course {
  13. width: 1020px;
  14. }
  15. /* 布局 */
  16. .biaoti {
  17. display: flex;
  18. place-content: space-between;
  19. place-items: center;
  20. }
  21. .courses-list {
  22. display: grid;
  23. grid-template-columns: repeat(5, 1fr);
  24. gap: 30px 10px;
  25. }
  26. .list img {
  27. width: 100%;
  28. border-radius: 5px 5px 0 0;
  29. position: static;
  30. z-index: 1;
  31. }
  32. /* 图片放大 */
  33. .list img:hover {
  34. transform: scale(1.1);
  35. transition: 0.3s;
  36. }
  37. .course {
  38. /* border: 1px solid #000; */
  39. }
  40. .list {
  41. background-color: white;
  42. border-radius: 5px;
  43. /* 图片溢出隐藏 */
  44. overflow: hidden;
  45. }
  46. .list .desc {
  47. padding: 15px;
  48. position: static;
  49. z-index: 2;
  50. }
  51. .list .desc .tag {
  52. font-size: x-small;
  53. color: blue;
  54. background-color: lightcyan;
  55. padding: 3px 5px;
  56. border-radius: 3px;
  57. }
  58. .list .desc a {
  59. line-height: 22px;
  60. }
  61. .list .desc .other {
  62. color: #aaa;
  63. font-size: xx-small;
  64. display: flex;
  65. place-content: space-between;
  66. margin-top: 8px;
  67. }
  68. .other .iconfont {
  69. font-size: 12px;
  70. margin-right: 3px;
  71. }
  72. .other span:last-child:hover {
  73. cursor: pointer;
  74. color: red;
  75. }

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议
PHP中文网用户-64065562023-03-27 16:31:401楼
层级不知道该如何做