Blogger Information
Blog 40
fans 0
comment 1
visits 24385
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第13章 1225-grid实战,学习心得、笔记
努力工作--周工--Robin
Original
494 people have browsed it

今天所学心得、笔记

1、网格单元和容器中对齐的相关属性全部实例演示

项目在网格单元中的对齐方式

  1. <style>
  2. /*初始化*/
  3. * {
  4. margin: 0;
  5. padding: 0;
  6. box-sizing: border-box;
  7. }
  8. li {
  9. list-style: none;
  10. }
  11. .container {
  12. display: grid;
  13. border: 1px solid;
  14. width: 35em;
  15. height: 35em;
  16. grid-template-columns: repeat(4, 1fr);
  17. grid-template-rows: repeat(4, 1fr);
  18. gap: .5em;
  19. }
  20. .container .item {
  21. width: 3.5em;
  22. height: 3.5em;
  23. border: 1px solid;
  24. background-color: pink;
  25. text-align: center;
  26. line-height: 3em;
  27. }
  28. /*项目网格对齐*/
  29. .container {
  30. /*左上角*/
  31. place-items: start start;
  32. /*右上角*/
  33. place-items: start right;
  34. /*左下角*/
  35. place-items: end left;
  36. /*右下角*/
  37. place-items: end right;
  38. /*正中*/
  39. place-items: center center;
  40. /*正中,简写*/
  41. place-items: center;
  42. }
  43. /*10号项目,单独上右对齐*/
  44. .container .item:nth-of-type(13),
  45. .container .item:nth-of-type(10),
  46. .container .item:nth-of-type(7),
  47. .container .item:nth-of-type(4)
  48. {
  49. place-self: start right;
  50. }
  51. </style>

项目在网格容器中的对齐方式

  1. <style>
  2. .container {
  3. width: 35em;
  4. height: 35em;
  5. border: 1px solid;
  6. display: grid;
  7. grid-template-columns: repeat(4, 5em);
  8. grid-template-rows: repeat(4, 5em);
  9. gap: .5em;
  10. /*项目在网格单元中对齐*/
  11. place-items: center;
  12. }
  13. .container .item {
  14. width: 3.5em;
  15. height: 3.5em;
  16. background-color: pink;
  17. text-align: center;
  18. line-height: 3.5em;
  19. }
  20. /*项目在网格容器中对齐*/
  21. .container {
  22. /*上左*/
  23. place-content: start left;
  24. place-content: start;
  25. /*上右*/
  26. place-content: start right;
  27. /*下左*/
  28. place-content: end left;
  29. /*下右*/
  30. place-content: end right;
  31. place-content: end;
  32. /*居中*/
  33. place-content: center;
  34. /*--------------------------------------------*/
  35. /*两端对齐*/
  36. place-content: space-between;
  37. /*元素上下左右,四边剩余空间相等*/
  38. place-content: space-around;
  39. /*剩余空间平均分配*/
  40. place-content: space-evenly;
  41. /*元素上下剩余空间相等,左右空间剩余平均分配*/
  42. place-content: space-around space-evenly;
  43. }
  44. </style>

2、快速实现php.cn首页主要组件的布局

示例截图

" class="reference-link">

3、理解grid的媒体查询与专业的媒体查询有什么区别?

  1. 个人理解如下,不知对不对:
  2. 1、专业媒体查询,是通过系统监视浏览器窗口的大小,根据设定的阀值来调整html元素字号的大小,从而调整页面布局;
  3. 2、grid的媒体查询,是通过auto-fit属性,自适应调整“列”的数量,从而调整页面布局;
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