Blogger Information
Blog 10
fans 0
comment 0
visits 8190
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex PC端布局
骨头
Original
957 people have browsed it
  1. <style>
  2. *,
  3. ::before,
  4. ::after {
  5. margin: 0px; /*清除外边距*/
  6. padding: 0px; /*清除内边距*/
  7. box-sizing: border-box; /*将盒子换为IE盒子 边框和内边距将不占据盒子大小*/
  8. }
  9. .box {
  10. display: flex; /*将最大的容器转换弹性盒子*/
  11. flex-flow: column nowrap; /*主轴为垂直排列 不换行*/
  12. background-color: #f3f5f7; /*背景颜色*/
  13. }
  14. /*导航*/
  15. header {
  16. background-color: #000; /*导航背景颜色*/
  17. height: 3em; /*高度*/
  18. display: flex; /*将导航父容器转换为弹性盒子*/
  19. flex-flow: row; /*主轴方向横向排列 */
  20. align-items: center; /*交叉轴垂直居中*/
  21. }
  22. header > a {
  23. text-decoration: none; /*去掉a标签的下划线*/
  24. color: rgba(255, 255, 255, 0.7); /*字体颜色*/
  25. flex: 1; /*项目自动分配宽度*/
  26. text-align: center; /*文本居中*/
  27. }
  28. /*主体*/
  29. .box > .container {
  30. margin-top: 2em; /*主体盒子上外边距*/
  31. display: flex; /*将主体转换弹性盒子*/
  32. border: 1px solid; /*边框线*/
  33. min-height: 40em; /*最小高度*/
  34. justify-content: center; /*主轴对齐方式*/
  35. }
  36. .container div {
  37. border: 1px solid;
  38. }
  39. .container div:first-of-type {
  40. flex: 0 0 20%;
  41. } /*主体内容里面的第一个项目占20%*/
  42. .container div:nth-of-type(2) {
  43. flex: 0 0 40%;
  44. } /*主体内容里面的第二个项目占40%*/
  45. .container div:last-of-type {
  46. flex: 0 0 20%;
  47. } /*主体内容里面的最后一个项目占20%*/
  48. /*底部*/
  49. footer {
  50. margin-top: 1em; /*底部盒子上外边距*/
  51. display: flex; /*将容器转换为弹性盒子*/
  52. flex-flow: column nowrap; /*主轴横向对齐 不换行*/
  53. text-align: center; /*文本居中对齐*/
  54. border: 1px solid; /*边框线*/
  55. background-color: #fff; /*背景颜色*/
  56. }
  57. @media screen and (max-width: 900px) {
  58. .container div:last-of-type {
  59. display: none;
  60. } /*当宽度小于900px时 主体内容里的right不显示*/
  61. }
  62. @media screen and (max-width: 700px) {
  63. header > a:not(:nth-of-type(-n + 5)) {
  64. display: none;
  65. } /*当宽度小于700px时 只显示前5个导航*/
  66. }
  67. </style>
  68. <body>
  69. <div class="box">
  70. <!--导航-->
  71. <header>
  72. <a href="#">LOGO</a>
  73. <a href="#">首页</a>
  74. <a href="#">视频教程</a>
  75. <a href="#">入门教程</a>
  76. <a href="#">社区问答</a>
  77. <a href="#">技术文章</a>
  78. <a href="#">资源下载</a>
  79. <a href="#">编程词典</a>
  80. <a href="#">工具下载</a>
  81. <a href="#">PHP培训</a>
  82. </header>
  83. <!--主体-->
  84. <div class="container">
  85. <div class="left"><h1>头条</h1></div>
  86. <div class="middle"><h1>最新课程</h1></div>
  87. <div class="right"><h1>常用手册</h1></div>
  88. </div>
  89. <!--底部-->
  90. <footer>
  91. <p>php中文网:公益在线php培训,帮助PHP学习者快速成长!</p>
  92. <p>
  93. Copyright 2014-2020 https://www.php.cn/ All Rights Reserved |
  94. 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1
  95. </p>
  96. </footer>
  97. </div>
  98. </body>

效果:

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