博客列表 >grid布局实例

grid布局实例

Wu.Ang
Wu.Ang原创
2022年08月11日 13:47:08414浏览

grid布局实例

html代码

  1. <!--右侧信息栏-->
  2. <div class="right">
  3. <!-- 个人信息 -->
  4. <div class="user">
  5. <!-- 图片 -->
  6. <div class="picture"><img width="20px" src="static/images/user-pic.jpeg" alt=""></div>
  7. <!-- 名字 -->
  8. <div class="name">Wu.Ang</div>
  9. <!-- P豆 -->
  10. <div class="p_bean">P豆:25</div>
  11. <!-- 我的学习 -->
  12. <div class="btn"><a href="">我的学习</a></div>
  13. </div>
  14. <!-- 问答社区 -->
  15. <div class="community">
  16. <div class="wenda">
  17. <span>问答社区</span>
  18. <a href="">答疑</a>
  19. </div>
  20. <div class="dh">
  21. <div class="dh-left">
  22. <div>
  23. <span>头条</span>
  24. <a href="">国产API管理神器 Apifox 好用吗?</a>
  25. </div>
  26. <div>
  27. <span>福利</span>
  28. <a href="">限时折扣>></a>
  29. </div>
  30. <div>
  31. <span>新班</span>
  32. <a href="">PHP阶段报名了</a>
  33. </div>
  34. <div>
  35. <span>招募</span>
  36. <a href="">课程合作计划</a>
  37. </div>
  38. <div>
  39. <span>公告</span>
  40. <a href="">APP上线啦</a>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <!--底部公众号-->
  47. <!-- 公众号 -->
  48. <div class="bottom-right">
  49. <div class="weixin">
  50. <img src="static/images/tlbb.png" alt="">
  51. </div>
  52. <div class="qq">
  53. <img src="static/images/ynxj.png" alt="">
  54. </div>
  55. <div><a href="">官方公众号</a></div>
  56. <div><a href="">官方QQ号</a></div>
  57. </div>

css代码部分

  1. /* `````````````右侧信息```````````````````````` */
  2. /* 个人信息 */
  3. main .navs .right .user{
  4. height: 141px;
  5. border-bottom: 1px solid #eeeeee;
  6. display: grid;
  7. padding-top: 20px;
  8. grid-template-columns: 40px 100px;
  9. grid-template-rows: 20px 20px 1fr;
  10. place-items: center;
  11. place-content: center;
  12. }
  13. main .navs .right .user .name,
  14. main .navs .right .user .p_bean{
  15. place-self: start;
  16. }
  17. main .navs .right .user .name{
  18. font-weight: bold;
  19. }
  20. main .navs .right .user .p_bean{
  21. font-size: 12px;
  22. color: #999999;
  23. }
  24. main .navs .right .user .picture{
  25. width: 40px;
  26. height: 40px;
  27. grid-row: span 2;
  28. }
  29. main .navs .right .user .picture img{
  30. width: 100%;
  31. border-radius: 50%;
  32. }
  33. main .navs .right .user .btn{
  34. grid-column: span 2;
  35. }
  36. main .navs .right .user .btn a{
  37. width: 100px;
  38. height: 50px;
  39. padding: 10px 40px;
  40. border-radius: 30px;
  41. background-color: red;
  42. color: white;
  43. font-weight: bold;
  44. border: 1px solid;
  45. }
  46. /* 问答社区 */
  47. main .navs .community{
  48. width: 150px;
  49. margin: auto;
  50. }
  51. main .navs .community .wenda{
  52. margin-top: 10px;
  53. display: flex;
  54. }
  55. main .navs .community .wenda a{
  56. width: 31px;
  57. color: white;
  58. background-color: #ff583d;
  59. text-align: center;
  60. margin:0 10px;
  61. }
  62. main .navs .community .dh{
  63. width: 150px;
  64. height: 240px;
  65. margin-top: 20px;
  66. }
  67. main .navs .community .dh .dh-left > div{
  68. display: grid;
  69. grid-template-columns: 30px 1fr;
  70. grid-auto-rows: 40px;
  71. overflow: hidden;
  72. }
  73. main .navs .community .dh .dh-left > div > a{
  74. color: #b6b6b6;
  75. margin-left: 20px;
  76. }
  77. main .navs .community .dh .dh-left > div > a:hover{
  78. color: red;
  79. }
  80. /* ````````````````````````````````````````` */
  81. /* ``````````````````底部公众号``````````````````````` */
  82. main .navs .bottom-right{
  83. display: grid;
  84. grid-template-columns: 70px 70px;
  85. grid-template-rows: 50px 20px;
  86. place-content: center;
  87. place-items: center;
  88. }
  89. main .navs .bottom-right .weixin img,
  90. main .navs .bottom-right .qq img{
  91. width: 30px;
  92. border-radius: 50%;
  93. }
  94. main .navs .bottom-right div a,
  95. main .navs .bottom-right div a{
  96. font-size: 12px;
  97. }
  98. /* ```````````````````````````````````````````` */

项目中的不足

  1. 对多行多列的grid布局运用的不好
  2. flex布局没有用到
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议