<bdo id='MhJ2q'></bdo><ul id='MhJ2q'></ul>

    1. <i id='MhJ2q'><tr id='MhJ2q'><dt id='MhJ2q'><q id='MhJ2q'><span id='MhJ2q'><b id='MhJ2q'><form id='MhJ2q'><ins id='MhJ2q'></ins><ul id='MhJ2q'></ul><sub id='MhJ2q'></sub></form><legend id='MhJ2q'></legend><bdo id='MhJ2q'><pre id='MhJ2q'><center id='MhJ2q'></center></pre></bdo></b><th id='MhJ2q'></th></span></q></dt></tr></i><div id='MhJ2q'><tfoot id='MhJ2q'></tfoot><dl id='MhJ2q'><fieldset id='MhJ2q'></fieldset></dl></div>
      <tfoot id='MhJ2q'></tfoot>
    2. <legend id='MhJ2q'><style id='MhJ2q'><dir id='MhJ2q'><q id='MhJ2q'></q></dir></style></legend>

      <small id='MhJ2q'></small><noframes id='MhJ2q'>

      使用 flexbox 获取 pinterest 或 jQuery 砌体布局

      using flexbox to get pinterest or jQuery masonry layout(使用 flexbox 获取 pinterest 或 jQuery 砌体布局)
        <tbody id='dqM2L'></tbody>

        <small id='dqM2L'></small><noframes id='dqM2L'>

          <bdo id='dqM2L'></bdo><ul id='dqM2L'></ul>
          <legend id='dqM2L'><style id='dqM2L'><dir id='dqM2L'><q id='dqM2L'></q></dir></style></legend>

        • <i id='dqM2L'><tr id='dqM2L'><dt id='dqM2L'><q id='dqM2L'><span id='dqM2L'><b id='dqM2L'><form id='dqM2L'><ins id='dqM2L'></ins><ul id='dqM2L'></ul><sub id='dqM2L'></sub></form><legend id='dqM2L'></legend><bdo id='dqM2L'><pre id='dqM2L'><center id='dqM2L'></center></pre></bdo></b><th id='dqM2L'></th></span></q></dt></tr></i><div id='dqM2L'><tfoot id='dqM2L'></tfoot><dl id='dqM2L'><fieldset id='dqM2L'></fieldset></dl></div>
              1. <tfoot id='dqM2L'></tfoot>

              2. 本文介绍了使用 flexbox 获取 pinterest 或 jQuery 砌体布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                想知道仅使用新的 flexbox 布局是否可以获得与 pinterest 或 jQuery masonry 相同类型的设计布局.据我所知:

                .flex-container {显示:-webkit-flex;显示:弹性;-webkit-flex-flow:行换行;flex-flow:行包装;}.物品 {宽度:220px;高度:250px;边距:10px 自动;填充:0;背景:#ccc;}.item:nth-child(3n+2) {背景:#aaa;高度:400px;}

                和 HTML 我只是使用 PHP 循环来创建 12 个项目

                解决方案

                完全有可能.

                感谢@leopld 的原始答案,我能够创建一个不依赖于固定高度的答案.

                通过将 flex 容器设置为 position: absoluteposition: fixed,您可以让它动态填充可用空间.

                代码笔链接:http://codepen.io/anon/pen/Jpnyj?editors=110.我包括了您此时需要的所有供应商前缀.

                标记

                <div class="box box-red"></div><div class="box box-blue"></div><div class="box box-pink"></div><div class="box box-purple"></div><div class="box box-green"></div><div class="box box-yellow"></div><div class="box box-brown"></div><div class="box box-red"></div><div class="box box-blue"></div><div class="box box-pink"></div><div class="box box-purple"></div><div class="box box-green"></div><div class="box box-purple"></div><div class="box box-green"></div><div class="box box-yellow"></div><div class="box box-blue"></div><div class="box box-pink"></div><div class="box box-purple"></div><div class="box box-green"></div><div class="box box-yellow"></div><div class="box box-red"></div><div class="box box-brown"></div><div class="box box-blue"></div><div class="box box-red"></div><div class="box box-green"></div><div class="box box-yellow"></div><div class="box box-brown"></div>

                样式

                body {背景:黑色;}.包装{位置:绝对;宽度:100%;高度:100%;显示:-webkit-box;显示:-webkit-flex;显示:-ms-flexbox;显示:弹性;-webkit-flex-flow:列换行;-ms-flex-flow:列换行;flex-flow:列包装;-webkit-box-align:拉伸;-webkit-align-items:拉伸;-ms-flex-align:拉伸;对齐项目:拉伸;-webkit-align-content:拉伸;-ms-flex-line-pack:拉伸;对齐内容:拉伸;}.盒子 {边距:5px;-webkit-box-flex: 0;-webkit-flex:0 1 自动;-ms-flex:0 1 自动;弹性:0 1 自动;}.box-红色{高度:100px;背景:红色;}.box-blue {高度:120px;背景:蓝色;}.box-粉红色{高度:144px;背景:粉红色;}.box-紫色{高度:250px;背景:紫色;}.box-green {高度:200px;背景:绿色;}.box-黄色{高度:20px;背景:黄色;}.box-brown {高度:290px;背景:棕色;}

                Wanted to know if it is possible to get the same type of design layout as pinterest or jQuery masonry using only the new flexbox layout. Here is as far as I got it:

                .flex-container {
                    display: -webkit-flex;
                    display: flex;
                    -webkit-flex-flow: row wrap;
                    flex-flow: row wrap;
                }
                .item {
                    width: 220px;
                    height: 250px;
                    margin: 10px auto;
                    padding: 0;
                    background: #ccc;
                }
                .item:nth-child(3n+2) {
                    background: #aaa;
                    height: 400px;
                }
                

                and the HTML I am just using a PHP loop to create 12 items

                <?php
                    for ($i=0; $i<=11; $i++) {
                        echo '<div class="item"></div>';
                    }
                ?>
                

                解决方案

                It is entirely possible.

                Thanks to @leopld's original answer, I was able to create one that does not depend on a fixed height.

                By making the flex container position: absolute or position: fixed, you are able to get it to fill the available space dynamically.

                Link to the Codepen: http://codepen.io/anon/pen/Jpnyj?editors=110. I included all the vendor prefixes you'd need at this time.

                Markup

                <div class="wrapper">
                    <div class="box box-red"></div>
                    <div class="box box-blue"></div>
                    <div class="box box-pink"></div>
                    <div class="box box-purple"></div>
                    <div class="box box-green"></div>
                    <div class="box box-yellow"></div>
                    <div class="box box-brown"></div>
                    <div class="box box-red"></div>
                    <div class="box box-blue"></div>
                    <div class="box box-pink"></div>
                    <div class="box box-purple"></div>
                    <div class="box box-green"></div>
                    <div class="box box-purple"></div>
                    <div class="box box-green"></div>
                    <div class="box box-yellow"></div>
                    <div class="box box-blue"></div>
                    <div class="box box-pink"></div>
                    <div class="box box-purple"></div>
                    <div class="box box-green"></div>
                    <div class="box box-yellow"></div>
                    <div class="box box-red"></div>
                    <div class="box box-brown"></div>
                    <div class="box box-blue"></div>
                    <div class="box box-red"></div>
                    <div class="box box-green"></div>
                    <div class="box box-yellow"></div>
                    <div class="box box-brown"></div>
                </div>
                

                Styles

                body {
                    background: black;
                }
                
                .wrapper {
                    position: absolute;
                    width: 100%;
                    height: 100%;
                    display: -webkit-box;
                    display: -webkit-flex;
                    display: -ms-flexbox;
                    display: flex;
                    -webkit-flex-flow: column wrap;
                    -ms-flex-flow: column wrap;
                    flex-flow: column wrap;
                    -webkit-box-align: stretch;
                    -webkit-align-items: stretch;
                    -ms-flex-align: stretch;
                    align-items: stretch;
                    -webkit-align-content: stretch;
                    -ms-flex-line-pack: stretch;
                    align-content: stretch;
                }
                
                .box {
                    margin: 5px;
                    -webkit-box-flex: 0;
                    -webkit-flex: 0 1 auto;
                    -ms-flex: 0 1 auto;
                    flex: 0 1 auto;
                }
                
                .box-red {
                    height: 100px;
                    background: red;
                }
                
                .box-blue {
                    height: 120px;
                    background: blue;
                }
                
                .box-pink {
                    height: 144px;
                    background: pink;
                }
                
                .box-purple {
                    height: 250px;
                    background: purple;
                }
                
                .box-green {
                    height: 200px;
                    background: green;
                }
                
                .box-yellow {
                    height: 20px;
                    background: yellow;
                }
                
                .box-brown {
                    height: 290px;
                    background: brown;
                }
                

                这篇关于使用 flexbox 获取 pinterest 或 jQuery 砌体布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Proxy Authentication Required with cURL(cURL 需要代理身份验证)
                How to use a SOCKS 5 proxy with cURL?(如何使用带有 cURL 的 SOCKS 5 代理?)
                How to use HTTP_X_FORWARDED_FOR properly?(如何正确使用 HTTP_X_FORWARDED_FOR?)
                file_get_contents behind a proxy?(代理后面的 file_get_contents ?)
                pecl install cassandra throws: quot;error: Unable to load libcassandraquot;(pecl install cassandra 抛出:“错误:无法加载 libcassandra)
                Installing php datastax driver on ubuntu(在 ubuntu 上安装 php datastax 驱动)

                  <legend id='jIx0l'><style id='jIx0l'><dir id='jIx0l'><q id='jIx0l'></q></dir></style></legend>
                1. <i id='jIx0l'><tr id='jIx0l'><dt id='jIx0l'><q id='jIx0l'><span id='jIx0l'><b id='jIx0l'><form id='jIx0l'><ins id='jIx0l'></ins><ul id='jIx0l'></ul><sub id='jIx0l'></sub></form><legend id='jIx0l'></legend><bdo id='jIx0l'><pre id='jIx0l'><center id='jIx0l'></center></pre></bdo></b><th id='jIx0l'></th></span></q></dt></tr></i><div id='jIx0l'><tfoot id='jIx0l'></tfoot><dl id='jIx0l'><fieldset id='jIx0l'></fieldset></dl></div>

                  <small id='jIx0l'></small><noframes id='jIx0l'>

                    • <bdo id='jIx0l'></bdo><ul id='jIx0l'></ul>

                        1. <tfoot id='jIx0l'></tfoot>
                            <tbody id='jIx0l'></tbody>