Blogger Information
Blog 63
fans 8
comment 8
visits 50357
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Flex通用布局-含头部及底部三列主体(中间自适应)
周Sir-BLOG
Original
1004 people have browsed it

Flex通用布局-含头部及底部三列主体(中间自适应)

布局要求

  • 使用Flex布局,包含头部及底部,主体三列布局,中间自适应;
  • 头部/底部要求100%宽度;
  • 主体宽度不超过1200px。

效果图如下

DOM结构如下:

  1. <div class="header">header</div>
  2. <div class="container">
  3. <div class="left">left</div>
  4. <div class="main">main</div>
  5. <div class="right">right</div>
  6. </div>
  7. <div class="footer">footer</div>

CSS(Flex布局):

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. box-sizing: border-box;
  5. }
  6. .header,
  7. .footer {
  8. height: 40px;
  9. background: #f1f0f0;
  10. }
  11. .container {
  12. display: flex;
  13. max-width: 1200px; /*主体宽度不超过1200px,又要自适应缩小,宽度应该用max-width*/
  14. margin: 10px auto;
  15. min-height: 600px;
  16. }
  17. .container .left,
  18. .right {
  19. width: 200px;
  20. background: #f1f0f0;
  21. }
  22. .container .main {
  23. width: 100%;
  24. margin: 0 10px;
  25. background: #f1f0f0;
  26. }
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