Blogger Information
Blog 13
fans 0
comment 0
visits 10281
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1228-Grid重写
Original
455 people have browsed it

HTML

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <link rel="stylesheet" href="Gird-ZY.css">
  8. <title>Grid</title>
  9. </head>
  10. <body>
  11. <div class="public-headline">
  12. <span>素材交易</span>
  13. </div>
  14. <!-- 标题组件 -->
  15. <div class="public-headline-demo">
  16. <!-- 标题 -->
  17. <div class="title1">
  18. <a href="">图库</a>
  19. <span>便宜 方便 安全</span>
  20. </div>
  21. <div class="title2">
  22. <span>热门图库</span>
  23. <a href="">明星</a>
  24. <a href="">动图</a>
  25. <a href="">搞笑</a>
  26. <a href="">表情包</a>
  27. <a href="">风景</a>
  28. <a href="">插画</a>
  29. <a href="">手绘</a>
  30. <a href="">名画</a>
  31. </div>
  32. <div class="pic">
  33. <!-- 左侧 -->
  34. <div class="pic-list">
  35. <!-- 图片预览 -->
  36. <div class="intro">
  37. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  38. <a href="">明星</a>
  39. <div>
  40. <span>&yen;998</span>
  41. <span>明星</span>
  42. </div>
  43. </div>
  44. <div class="intro">
  45. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  46. <a href="">动图</a>
  47. <div>
  48. <span>&yen;998</span>
  49. <span>动图</span>
  50. </div>
  51. </div>
  52. <div class="intro">
  53. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  54. <a href="">搞笑</a>
  55. <div>
  56. <span>&yen;998</span>
  57. <span>搞笑</span>
  58. </div>
  59. </div>
  60. <div class="intro">
  61. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  62. <a href="">表情包</a>
  63. <div>
  64. <span>&yen;998</span>
  65. <span>表情包</span>
  66. </div>
  67. </div>
  68. <div class="intro">
  69. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  70. <a href="">风景</a>
  71. <div>
  72. <span>&yen;998</span>
  73. <span>风景</span>
  74. </div>
  75. </div>
  76. <div class="intro">
  77. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  78. <a href="">插画</a>
  79. <div>
  80. <span>&yen;998</span>
  81. <span>插画</span>
  82. </div>
  83. </div>
  84. <div class="intro">
  85. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  86. <a href="">手绘</a>
  87. <div>
  88. <span>&yen;998</span>
  89. <span>手绘</span>
  90. </div>
  91. </div>
  92. <div class="intro">
  93. <a href=""><img src="../static/images/11.jpg" alt="" width="180px" height="150px"></a>
  94. <a href="">名画</a>
  95. <div>
  96. <span>&yen;998</span>
  97. <span>名画</span>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- 右侧 -->
  102. <div class="ad-list">
  103. <a href=""><img src="../static/images/ad/1.png" alt=""></a>
  104. <a href=""><img src="../static/images/ad/2.png" alt=""></a>
  105. <a href=""><img src="../static/images/ad/3.png" alt=""></a>
  106. <a href=""><img src="../static/images/ad/4.png" alt=""></a>
  107. <div>
  108. <a href=""><img src="../static/images/ad/image.png" alt=""></a>
  109. <a href=""><img src="../static/images/ad/ad2.jpg" alt=""></a>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </body>
  115. </html>

CSS

  1. /* 通用样式 */
  2. *{
  3. margin: 0;
  4. padding: 0;
  5. /* outline: 1px dashed red; */
  6. }
  7. body{
  8. font-size: 13px;
  9. color: cdcdcd;
  10. background-color: efefef;
  11. }
  12. a{
  13. color: #404040;
  14. text-decoration: none;
  15. font-size: 13px;
  16. }
  17. li{
  18. list-style: none;
  19. }
  20. .public-headline{
  21. padding: 30px;
  22. text-align: center;
  23. }
  24. .public-headline span{
  25. font-size: 30px;
  26. font-weight: bolder;
  27. padding-bottom: 7px;
  28. border-bottom: 2px solid rebeccapurple;
  29. }
  30. /* 大标题 */
  31. .public-headline-demo{
  32. width: 1200px;
  33. padding: 10px;
  34. box-sizing: border-box;
  35. margin: auto;
  36. border-radius: 5px;
  37. border-color: #fff;
  38. }
  39. .public-headline-demo:hover{
  40. box-shadow: 0 0 5px #888;
  41. }
  42. /* 图库 */
  43. .public-headline-demo > .title1{
  44. height: 50px;
  45. border-bottom: 1px solid #ccc;
  46. box-sizing: border-box;
  47. }
  48. .public-headline-demo > .title1 >a{
  49. font-size: 23px;
  50. margin-right: 20px;
  51. }
  52. .public-headline-demo>.title1>span{
  53. color: red;
  54. }
  55. /* 热门图库 */
  56. .public-headline-demo > .title2{
  57. height: 55px;
  58. border-bottom: 1px solid #cdcdcd;
  59. line-height: 55px;
  60. }
  61. .public-headline-demo>.title2>span{
  62. color: red;
  63. font-size: 23px;
  64. }
  65. .public-headline-demo>.title2>span ~a{
  66. padding-left: 20px;
  67. }
  68. .public-headline-demo>.title2>span ~a:hover{
  69. color: royalblue;
  70. }
  71. /* 图片展示区 */
  72. .public-headline-demo>.pic{
  73. height: 440px;
  74. display: grid;
  75. grid-template-columns: 2fr 1fr;
  76. /* grid-column-gap: 5px; */
  77. }
  78. .public-headline-demo>.pic>.pic-list{
  79. display: grid;
  80. grid-template-columns: repeat(4,1fr);
  81. grid-template-rows: repeat(2,1fr);
  82. }
  83. .public-headline-demo>.pic>.pic-list>.intro span:first-of-type{
  84. color: red;
  85. }
  86. .public-headline-demo>.pic>.pic-list>.intro >div{
  87. display: grid;
  88. grid-template-columns: 1fr 1fr;
  89. /* grid-column-gap: 20px; */
  90. }
  91. .public-headline-demo>.pic>.pic-list>.intro span:last-of-type{
  92. color: white;
  93. background-color: #55ce9f;
  94. margin-left: auto;
  95. }
  96. /* 广告 */
  97. .public-headline-demo > .pic > .ad-list {
  98. display: grid;
  99. grid-template-columns: 210px 210px;
  100. grid-template-rows: 150px 150px;
  101. }
  102. .public-headline-demo > .pic > .ad-list img {
  103. width: 190px;
  104. height: 130px;
  105. }
  106. .public-headline-demo > .pic > .ad-list > div img {
  107. width: 393px;
  108. height: 60px;
  109. }

效果图

手写属性

总结

Grid会比flex更加简洁方便,有助于精简代码,更灵活的布局

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:是的, grid是处理一些大的二维页面时, 能力更强大
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post