我该如何编写这个CSS Flexbox布局?

时间:2015-11-04 17:51:56

标签: html css css3 layout flexbox

如何编写此CSS Flexbox布局? CSS Flexbox layout

1 个答案:

答案 0 :(得分:2)

使用嵌套网格绑定它。

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

这里有

MARKUP和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>