Blogger Information
Blog 7
fans 0
comment 2
visits 5349
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
grid布局作业练习
虫先森
Original
493 people have browsed it

grid布局作业练习

grid布局确实很好用,通过作业的训练,稍微熟悉了一些,之后应该还需要多练习一些,终于有一点自己在写一个网站的感觉了。

  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>grid操作练习</title>
  7. <style>
  8. /* 通用属性设置 */
  9. html {
  10. font-size: 14px;
  11. }
  12. body {
  13. display: flex;
  14. place-content: start center;
  15. background-color: azure;
  16. }
  17. img {
  18. width: 100%;
  19. height: 100%;
  20. }
  21. a {
  22. font-size: 1.2rem;
  23. text-decoration: none;
  24. }
  25. h3 {
  26. color: rgb(78, 21, 21);
  27. padding-left: 8px;
  28. }
  29. .tittle {
  30. color: black;
  31. font: 0.9em sans-serif;
  32. }
  33. .abstract {
  34. color: #353535;
  35. font: 0.7em sans-serif;
  36. }
  37. .container {
  38. /* 设置容器大小 */
  39. width: 90vw;
  40. height: 100vh;
  41. background-color: #ffffff;
  42. /* justify-content: stretch;
  43. align-content: stretch; */
  44. /* 创建grid容器 */
  45. display: grid;
  46. grid-template-rows: 70px 1fr 1fr 50px;
  47. grid-template-columns: 1fr 1fr 30%;
  48. /* 命名容器区域 */
  49. grid-template-areas:
  50. "header header header"
  51. ". . . "
  52. ". . . "
  53. "footer footer footer";
  54. /* 项目对齐方式 */
  55. place-items: center;
  56. gap: 2px;
  57. }
  58. /* 设置项目基本属性 */
  59. .item {
  60. background-color: #fff;
  61. justify-self: stretch;
  62. align-self: stretch;
  63. }
  64. /* 设置页眉区域项目 */
  65. .item.item1 {
  66. background-color: #353535;
  67. grid-area: header;
  68. display: flex;
  69. justify-items: center;
  70. justify-content: space-between;
  71. align-items: center;
  72. align-content: center;
  73. }
  74. .item.item1>.logo {
  75. margin-left: 2vw;
  76. width: 180px;
  77. height: 40px;
  78. }
  79. .item.item1>.nav {
  80. list-style: none;
  81. display: flex;
  82. justify-content: space-around;
  83. width: 100%;
  84. text-align: right;
  85. color: goldenrod;
  86. }
  87. .item.item1>.nav>li>a>span {
  88. color: goldenrod;
  89. }
  90. .item.item2 {
  91. width: 100%;
  92. height: 100%;
  93. background-color: lightcoral;
  94. grid-area: 2/1/3/3;
  95. }
  96. .item.item3,
  97. .item.item4 {
  98. height: auto;
  99. padding-right: 5px;
  100. border: 1px #c0c0c0 solid;
  101. background-color: #ebebeb;
  102. border-radius: 5px;
  103. }
  104. .item.item3>ul>li,
  105. .item.item4>ul>li {
  106. margin: 5px 2px;
  107. }
  108. .item.item5 {
  109. height: auto;
  110. background-color: #f9f9f9;
  111. grid-area: 2/3/span 2/span 1;
  112. border: 1px #c0c0c0 solid;
  113. border-radius: 7px;
  114. display: flex;
  115. flex-flow: column nowrap;
  116. place-items: center;
  117. padding: 10px;
  118. }
  119. .item.item5>.touxiang {
  120. width: 50%;
  121. }
  122. /* 设置页脚区域项目 */
  123. .item.item6 {
  124. display: flex;
  125. width: 100%;
  126. background-color: gray;
  127. grid-area: footer;
  128. justify-content: space-around;
  129. align-items: center;
  130. }
  131. .item.item6>a {
  132. text-decoration: none;
  133. }
  134. .item.item6>a>span,
  135. .item.item6>span {
  136. padding: 5px;
  137. text-decoration-line: none;
  138. color: honeydew;
  139. font-size: 12px;
  140. }
  141. </style>
  142. </head>
  143. <body>
  144. <div class="container">
  145. <div class="item item1">
  146. <div class="logo">
  147. <img src="images/logo.png" alt="logo">
  148. </div>
  149. <ul class="nav">
  150. <li><a href="" class="link"><span>首页</span></a></li>
  151. <li><a href="" class="link"><span>博客</span></a></li>
  152. <li><a href="" class="link"><span>相册</span></a></li>
  153. <li><a href="" class="link"><span>关于</span></a></li>
  154. </ul>
  155. </div>
  156. <div class="item item2">
  157. <img src="images/zxkc4.png" alt="公益直播课即将开播">
  158. </div>
  159. <div class="item item3">
  160. <h3>推荐阅读</h3>
  161. <ul>
  162. <li><a href=""><span class="tittle">css栅格化布局方式</span><br><span
  163. class="abstract">css的栅格化处理通常需要借助grid这一方式,grid可以将网页元素以...</span></a></li>
  164. <li><a href=""><span class="tittle">html表单属性的运用实例</span><br><span
  165. class="abstract">html的表单操作是一个十分重要的内容,特别是一些交互功能几乎依赖...</span></a></li>
  166. <li><a href=""><span class="tittle">使用小皮管理云服务器</span><br><span
  167. class="abstract">小皮面板是php中文网开发的一款用于php环境快速配置与管理...</span></a></li>
  168. </ul>
  169. </div>
  170. <div class="item item4">
  171. <h3>近期更新</h3>
  172. <ul>
  173. <li><a href=""><span class="tittle">css栅格化布局方式</span><br>
  174. <span class="abstract">css的栅格化处理通常需要借助grid这一方式,grid可以将网页元素以...</span></a></li>
  175. <li><a href=""><span class="tittle">html表单属性的运用实例</span><br>
  176. <span class="abstract">html的表单操作是一个十分重要的内容,特别是一些交互功能几乎依赖...</span></a></li>
  177. <li><a href=""><span class="tittle">使用小皮管理云服务器</span><br>
  178. <span class="abstract">小皮面板是php中文网开发的一款用于php环境快速配置与管理...</span></a></li>
  179. </ul>
  180. </div>
  181. <div class="item item5">
  182. <div class="touxiang">
  183. <img src="images/login.png" alt="头像">
  184. </div>
  185. <h3>张三</h3>
  186. <p>您于2020年4月14日 14:32 在 中国上海市 登录本站。</p>
  187. <div class="">
  188. <h4>按月份排列</h4>
  189. <ul>
  190. <li><a href=""><span class="tittle">2020年04月</span><span class="abstract">(4)</span></a></li>
  191. <li><a href=""><span class="tittle">2020年03月</span><span class="abstract">(12)</span></a></li>
  192. <li><a href=""><span class="tittle">2020年01月</span><span class="abstract">(3)</span></a></li>
  193. <li><a href=""><span class="tittle">2019年12月</span><span class="abstract">(1)</span></a></li>
  194. </ul>
  195. </div>
  196. </div>
  197. <div class="item item6">
  198. <a href=""><span>网站地图</span></a>
  199. <a href=""><span>博客管理</span></a>
  200. <a href=""><span>联系站长</span></a>
  201. <a href=""><span>留言</span></a>
  202. <span>本站文章仅代表作者个人观点,未经允许不得转载</span>
  203. </div>
  204. </div>
  205. </body>
  206. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:现在是不是对写一个站点, 心里有点数了
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
1 comments
虫先森 2020-04-14 19:04:57
有感觉多了,大概也有概念了,grid真的是一个神器,flex的时候感觉都不明显,grid用上,感觉就不一样了
1 floor
Author's latest blog post