Blogger Information
Blog 19
fans 1
comment 0
visits 13309
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex布局基础知识--php培训第九期线上班
涤尘
Original
629 people have browsed it

自学:align-self, order的用法

order:定义项目的排列顺序。数值越小,排列越靠前,默认为0
align-self该属性允许单个项目有与其它项目不一样的对齐方式, 可覆盖掉容器的flex-items属性 默认值: auto,表示继承父元素的align-items,如果没有父元素,则等价于stretch
  1. .demo1 > .item:first-of-type {
  2. order: 10;
  3. }
  4. .demo1 > .item:nth-last-of-type(3) {
  5. order: 8;
  6. }
  7. .demo1 > .item:nth-last-of-type(2) {
  8. order: 6;
  9. }
  10. .demo1 > .item:last-of-type {
  11. order: 1;
  12. align-self: flex-end;
  13. }

演示效果

用flex布局改圣杯布局

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>圣杯布局</title>
  6. <style type="text/css">
  7. header,footer {
  8. box-sizing: border-box;
  9. background-color: green;
  10. height: 50px;
  11. border: 1px solid;
  12. }
  13. main {
  14. display: flex;
  15. }
  16. main > aside {
  17. height: 600px;
  18. width: 200px;
  19. background-color: lightgreen;
  20. flex: none;
  21. }
  22. main > article{
  23. height: 600px;
  24. width: 100%;
  25. background-color: blue;
  26. flex: auto;
  27. }
  28. main > aside:first-of-type {
  29. order: -1;
  30. }
  31. </style>
  32. </head>
  33. <body >
  34. <header>头部</header>
  35. <main>
  36. <article>主体内容区</article>
  37. <aside >左侧</aside>
  38. <aside >右侧</aside>
  39. </main>
  40. <footer>底部</footer>
  41. </body>
  42. </html>

效果图

总结:需要多写多练,关于flex要灵活运用。

手抄代码如下:











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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!