2015-11-04 88 views
-5

如何编写此Flex Flexbox布局? CSS Flexbox layout我如何写这个CSS Flexbox布局?

+2

欢迎堆栈溢出。尝试自己建造它。如果/当您遇到问题时,请在此处发布您的代码和问题描述,我们会尽力为您提供帮助。堆栈溢出是一种问答服务,而不是“从头开始”的代码写入服务。这里有一些更多的指导方针:http://stackoverflow.com/help/mcve –

+0

没有任何我知道的将处理左边的框相同的行容器中的其他四个匹配的高度。可能吗? –

+0

这对flexbox来说绝对有可能。研究嵌套的柔性盒。您还需要将右上角和左下角的柔性项目制作为柔性容器。你需要'flex-wrap:wrap'。祝你好运。 –

回答

2

通过使用嵌套网格钉住它。

Screenshot - Click image to view full size.enter image description here]

标记和CSS这里:

 <div class="flex flex-twin"> 
      <div class="box double">first box</div><!-- end box --> 
      <div class="box"> 
       <div class="flex flex-twin"> 
        <div class="box">second</div><!-- end box --> 
        <div class="box">third</div><!-- end box --> 
       </div><!-- end flex-twin --> 
       <div class="flex flex-twin"> 
        <div class="box">fourth</div><!-- end sub box --> 
        <div class="box">fifth</div><!-- end sub box --> 
       </div><!-- end flex-twin --> 
      </div><!-- end box --> 
     </div><!-- end flex-twin --> 

     <style> 
      .flex { 
       display: flex; 
       justify-content: space-between; 
       &.flex-twin { 
        .box { 
         width: 50%; 
         height: 200px; 
         background: #ccc; 
         &.double { 
          height: 400px; 
         } 
         .flex { 
          &.flex-twin { 
           .box { 
            background: #aaa; 
           } // end box 
          } // end flex-twin 
          .box { 

          } // end box 
         } // end flex 
        } // end box 
       } // end flex-twin 
       .box { 

       } // end box 
      } // end flex 
     </style>