php中文网首页"热门推荐"课程列表组件(

编辑: admin 分类: 电脑知识 发布时间: 2023-06-14 来源:互联网
HTML 部分
  1. <!doctype html>
  2. <html lang="cn-ZH">
  3. <head>
  4. ......
  5. <link rel="stylesheet" href="common.css">
  6. </head>
  7. <body>
  8. <header>
  9. <img src="https://www.php.cn/static/images/new/logo-2x.png" alt="php.cn">
  10. <p>程序员梦开始的地方</p>
  11. </header>
  12. <div class="mainContainer">
  13. <div class="hotCourses">
  14. <h3>热门推荐</h3>
  15. <div class="coursesList">
  16. <div class="course">
  17. <div class="image">
  18. <a href="">
  19. <img src="https://img.php.cn/upload/course/000/000/068/6250203a9746a798.jpg" alt="">
  20. </a>
  21. </div>
  22. <div class="description">
  23. <div class="title">
  24. <span class="tag">初级</span>
  25. <a href="">小白拯救者: PHP7基础语法快速预览</a>
  26. </div>
  27. <div class="other">
  28. <span>12345次学习</span>
  29. <a href="">
  30. <span class="iconfont icon-shoucang"></span>
  31. 收藏
  32. </a>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="course">......</div>
  37. <div class="course">......</div>
  38. <div class="course">......</div>
  39. <div class="course">......</div>
  40. <div class="course">......</div>
  41. <div class="course">......</div>
  42. <div class="course">......</div>
  43. <div class="course">......</div>
  44. <div class="course">......</div>
  45. </div>
  46. </div>
  47. </div>
  48. </body>
  49. </html>
CSS 部分
  1. @import url(//at.alicdn.com/t/c/font_3961095_ighe51lxm1h.css);
  2. *{
  3. margin: 0;
  4. padding: 0;
  5. box-sizing: border-box;
  6. }
  7. header{
  8. width: 1200px;
  9. margin: 0 auto;
  10. height: 6rem;
  11. line-height: 6rem;
  12. display: flex;
  13. background: white;
  14. }
  15. header>img{
  16. width: 140px;
  17. height: 32px;
  18. margin: auto 0;
  19. }
  20. header>p{
  21. width: 100%;
  22. font-weight: bold;
  23. font-size: 1.3rem;
  24. margin-left: 2rem;
  25. }
  26. .mainContainer{
  27. background: #efefef;
  28. }
  29. .hotCourses{
  30. width: 1200px;
  31. margin: 0 auto;
  32. padding-bottom: 1rem;
  33. }
  34. .hotCourses h3{
  35. height: 5rem;
  36. line-height: 5rem;
  37. }
  38. .hotCourses a{
  39. text-decoration: none;
  40. color: #555;
  41. }
  42. .hotCourses a:hover{
  43. color: red;
  44. }
  45. .hotCourses .coursesList{
  46. display: grid;
  47. grid-template-columns: repeat(5,1fr);
  48. gap: 30px 10px;
  49. }
  50. .hotCourses .coursesList .image{
  51. font-size: 0;
  52. overflow: hidden;
  53. border-top-left-radius: 6px;
  54. border-top-right-radius: 6px;
  55. }
  56. .hotCourses .coursesList img{
  57. width: 100%;
  58. }
  59. .hotCourses .coursesList img:hover{
  60. transform: scale(1.2);
  61. transition: 0.3s;
  62. }
  63. .hotCourses .coursesList .course{
  64. background: white;
  65. border-radius: 6px;
  66. }
  67. .hotCourses .coursesList .course .description{
  68. height: content-box;
  69. padding: 1rem;
  70. display: grid;
  71. gap: 1rem;
  72. }
  73. .hotCourses .coursesList .course .description .title{
  74. line-height: 1.5rem;
  75. }
  76. .hotCourses .coursesList .course .description .tag{
  77. color: red;
  78. background: lemonchiffon;
  79. padding: 0.2rem 0.4rem;
  80. font-size: 0.75rem;
  81. border-radius: 2px;
  82. }
  83. .hotCourses .coursesList .course .description .other{
  84. color: #aaa;
  85. font-size: 0.75rem;
  86. display: flex;
  87. place-content: space-between;
  88. }
  89. .hotCourses .coursesList .course .description .other a{
  90. color: #aaa;
  91. }
  92. .iconfont{
  93. font-size: 0.75rem;
  94. }
页面效果

问题

第二个课程的标题只有一行,导致下面的“阅读次数和收藏”向上移动,怎样才能让“阅读次数和收藏”的位置和第一课程的一致?

【感谢本站数字底座由龙石数据提供 http://www.longshidata.com/pages/government.html】