作家
登录

使用Flex实现5种常用布局

作者: 来源: 2017-12-07 15:09:47 阅读 我要评论

开辟者大年夜赛路演 | 12月16日,技巧立异,北京不见不散

Sticky Footer

经典的上-中-下构造。

Sticky Sidebar

当页面内容高度小于可视区域高度时,footer 吸附在底部;当页面内容高度大年夜于可视区域高度时,footer 被撑开排在 content 下方

demo link

  1. <body>  
  2.   
  3.   <header>HEADER</header>  
  4.   
  5.   <article>CONTENT</article>  
  6.   
  7.   <footer>FOOTER</footer>  
  8.   
  9. </body> 
  1. body { 
  2.  
  3.   min-height: 100vh; 
  4.  
  5.   display: flex; 
  6.  
  7.   flex-direction: column
  8.  
  9.  
  10. article { 
  11.  
  12.   flex: auto; 
  13.  
  1. body { 
  2.  
  3.   min-height: 100vh; 
  4.  
  5.   display: flex; 
  6.  
  7.  
  8. aside { 
  9.  
  10.   flex: none; 
  11.  
  12.  
  13. .content { 
  14.  
  15.   flex: auto; 
  16.  
  17.   display: flex; 
  18.  
  19.   flex-direction: column
  20.  
  21.  
  22. .content article { 
  23.  
  24.   flex: auto; 
  25.  

Fixed-Width Sidebar

在上-中-下构造的基本上,加了左侧定宽 sidebar。

demo link

  1. <body> 
  2.  
  3.   <header>HEADER</header> 
  4.  
  5.   <div class="content"
  6.  
  7.     <aside>ASIDE</aside> 
  8.  
  9.     <article>CONTENT</article> 
  10.  
  11.   </div> 
  12.  
  13.   <footer>FOOTER</footer> 
  14.  
  15. </body> 
  1. body { 
  2.  
  3.   min-height: 100vh; 
  4.  
  5.   display: flex; 
  6.  
  7.   flex-direction: column
  8.  
  9.  

  10.   推荐阅读

      全新AI人工智能操作系统崭露头角,将来Android或退出中国

    开辟者大年夜赛路演 | 12月16日,技巧立异,北京不见不散当前,国浑家多的手机品牌都标榜着本身手机有本身的体系,如小米的MIUI,华为EMUI,魅族的Flyme OS等等,不过,这些所谓的“体系”只>>>详细阅读


    本文标题:使用Flex实现5种常用布局

    地址:http://www.17bianji.com/lsqh/39562.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)