Blogger Information
Blog 22
fans 0
comment 0
visits 11769
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Grid容器属性与项目属性—Php第十期线上班
Original
506 people have browsed it

12.30作业

Grid布局容器属性


规划一个2x3的显式网格,项目中多处的7、8、9为隐式网格,容器的项目在网格和单元格中均以水平/垂直方向逆向对齐,代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Grid容器属性</title>
  6. <style>
  7. * :not(body){
  8. outline: 1px dashed red;
  9. }
  10. .container{
  11. width: 400px;
  12. height: 400px;
  13. display: grid;
  14. /*显式网格轨道*/
  15. grid-template-columns: repeat(3,100px);
  16. grid-template-rows: repeat(2,100px);
  17. /*创建隐式网格轨道*/
  18. /*grid-auto-flow:column;*/
  19. /*grid-auto-columns:150px;*/
  20. grid-auto-rows: 150px;
  21. /*创建轨道间距*/
  22. /*先上下后左右*/
  23. /*grid-column-gap:10px;*/
  24. /*grid-row-gap:20px;*/
  25. /*grid-gap:20px 10px;*/
  26. gap: 20px 10px;
  27. /*项目在网络容器中的对齐方式*/
  28. /*justify-content:end;*/
  29. /*align-content:end;*/
  30. place-content: end end;
  31. /*所有项目在单元格中的对齐方式*/
  32. /*justify-items:end;*/
  33. /*align-items: end;*/
  34. place-items: end end;
  35. }
  36. .item{
  37. height: 60px;
  38. width: 60px;
  39. font-size: 20px;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. <div class="container">
  45. <div class="item">1</div>
  46. <div class="item">2</div>
  47. <div class="item">3</div>
  48. <div class="item">4</div>
  49. <div class="item">5</div>
  50. <div class="item">6</div>
  51. <div class="item">7</div>
  52. <div class="item">8</div>
  53. <div class="item">9</div>
  54. </div>
  55. </body>
  56. </html>

Grid布局项目属性


规划一个3列的网格,其中将2号占据前3x3单元格,同时使其相对单元格水平/垂直方向逆向对齐,代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Grid项目属性</title>
  6. <style>
  7. * :not(body){
  8. outline: 1px dashed red;
  9. }
  10. .container {
  11. width: 400px;
  12. height: 400px;
  13. display: grid;
  14. grid-template-columns: repeat(3,100px);
  15. grid-template-areas:'a a a''a a a''a a a';
  16. }
  17. .item:nth-of-type(2){
  18. /*项目放置到单元格中*/
  19. /*grid-column-start:1;*/
  20. /*grid-column-end:4;*/
  21. grid-column:1/4;
  22. /*grid-row-start: 1;*/
  23. /*grid-row-end: 4;*/
  24. grid-row:1/4;
  25. /*grid-area:a;*/
  26. grid-area: 1 / 1 / 4 / 4 ;
  27. /*项目在单元格中的对齐方式*/
  28. justify-self:end;
  29. align-self:end;
  30. /*place-self:end;*/
  31. background-color: lightcyan;
  32. height: 100px;
  33. width: 100px;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div class="container">
  39. <div class="item">1</div>
  40. <div class="item">2</div>
  41. <div class="item">3</div>
  42. <div class="item">4</div>
  43. <div class="item">5</div>
  44. <div class="item">6</div>
  45. <div class="item">7</div>
  46. <div class="item">8</div>
  47. <div class="item">9</div>
  48. </div>
  49. </body>
  50. </html>

手抄Grid容器属性与项目属性


小结

Grid布局的属性为:justify-content/items/self水平方向排列,所有项目容器、所有项目单元格、单个项目单元格;align-content/items/self垂直方向排列,所有项目容器、所有项目单元格、单个项目单元格;place-content/items/self水平-垂直方向排列,所有项目容器、所有项目单元格、单个项目单元格。以此记忆比较简单。同时项目放置在单元格可以通过:1、放置在命名区域内;2、设置边界网格线。两种方式来实现。

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
0 comments
Author's latest blog post