博主信息
博文 10
粉丝 0
评论 0
访问量 13093
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
网格布局实现课程信息
xsrsblog
原创
806人浏览过

效果:

源码:

  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. /* padding: 0;
  10. margin: 0; */
  11. text-decoration: none;
  12. }
  13. /* 外层容器设置宽高、开启相对定位,
  14. 作为动态盒子的定位点 */
  15. .container {
  16. width: 150px;
  17. height: 140px;
  18. position: relative;
  19. border-radius: 5px;
  20. }
  21. /* 动态盒子开启绝对定位,并把bottom值设置为0,
  22. 调整盒子增长方向为由下往上 */
  23. .inner1 {
  24. font-size: 13px;
  25. height: 60px;
  26. transition: height 1s;
  27. /* border: 1px solid red; */
  28. position: absolute;
  29. bottom: 0px;
  30. color: gray;
  31. background-color: rgb(226, 226, 217);
  32. border-radius: 5px;
  33. }
  34. /* 开启定位,防止被inner1覆盖 */
  35. .inner2 {
  36. width: 100%;
  37. text-align: center;
  38. position: absolute;
  39. bottom: 0;
  40. /* border: 1px solid blue; */
  41. color: gray;
  42. }
  43. /* 伪类,盒子变高 */
  44. .container:hover .inner1 {
  45. height: 100px;
  46. /* background-color: lightblue; */
  47. }
  48. /* 网格布局,5列3行 */
  49. .gridBox {
  50. display: grid;
  51. grid-template-columns: repeat(5, 1fr);
  52. grid-template-rows: repeat(3, 1fr);
  53. width: 850px;
  54. height: 450px;
  55. /* border: 1px solid red; */
  56. }
  57. /* 区域设置 */
  58. .item1 {
  59. grid-column: 1/2;
  60. grid-row: 1/3;
  61. /* background-color: red; */
  62. }
  63. .item {
  64. margin: auto;
  65. }
  66. </style>
  67. </head>
  68. <body>
  69. <div class="gridBox">
  70. <div class="item item1">
  71. <a href=""><img src="黑莲花.jpg" alt="" style="width: 150px;" /></a>
  72. </div>
  73. <div class="item">
  74. <div class="container">
  75. <a href="#">
  76. <img
  77. src="黑莲花.jpg"
  78. alt=""
  79. style="width: 150px; display: inline-block;"
  80. />
  81. <div class="inner1">
  82. <i>初级</i>&nbsp;&nbsp;<span>MYSQL面向对象极速入门</span>
  83. <br />
  84. <br />
  85. </div>
  86. <div class="inner2">
  87. <span>20W+次播放</span>
  88. </div>
  89. </a>
  90. </div>
  91. </div>
  92. <!-- 重复12次<div class="item">...</div> -->
  93. </div>
  94. </body>
  95. </html>
批改老师:GuanhuiGuanhui

批改状态:合格

老师批语:完成的不是很好!还需努力!
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学