如何从6个项目制作这样的HTML网格系统?

时间:2016-06-30 01:34:40

标签: html5 css3 gridview masonry

我有一个包含9个项目的网格系统,我想要的是自定义当前的6个项目网格,如下所示:

enter image description here

这是我当前网格系统的一支笔:

https://codepen.io/anon/pen/NAjqzR

我的HTML代码:

<div class="container" style="max-width:1300px;">               
    <div class="row">
        <!-- col-left -->
          <div class="col-xs-12 col-sm-offset-2  col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-0">
            <a href="/collections/accessories" class="banner zoom-in">
        <span class="figure">
          <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/mens.png?14209798005151405036" alt=""/>
          <span class="figcaption">
            <span class="block-table">
              <span class="block-table-cell">
                <span class="banner__title size40">Mens</span>
                <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
              </span>
            </span>
          </span>
        </span>
      </a>
      <div class="divider"></div>
      <a href="/collections/skate" class="banner zoom-in">
        <span class="figure">
          <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/skates.png?14209798005151405036" alt=""/>
          <span class="figcaption">
            <span class="block-table">
              <span class="block-table-cell">
                <span class="banner__title size40">Skate</span>
                <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
              </span>
            </span>
          </span>
        </span>
      </a>
      <div class="divider"></div>
    </div>
        <!-- /col-left -->
        <!-- col-right -->
        <div class="col-xs-12 col-sm-offset-2  col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-0">
            <a href="/collections/accessories" class="banner zoom-in">
                <span class="figure">
                    <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/accessories_a2c62c03-a1fe-4b8d-96e3-0de1e87571bf.png?14209798005151405036" alt=""/>
                    <span class="figcaption">
                        <span class="block-table">
                            <span class="block-table-cell">
                                <span class="banner__title size40">Accessories</span>
                                <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
                            </span>
                        </span>
                    </span>
                </span>
            </a>
            <div class="divider"></div>
            <a href="/collections/skate" class="banner zoom-in">
                <span class="figure">
                    <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/boardshorts.png?14209798005151405036" alt=""/>
                    <span class="figcaption">
                        <span class="block-table">
                            <span class="block-table-cell">
                                <span class="banner__title size40">Boardshorts</span>
                                <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
                            </span>
                        </span>
                    </span>
                </span>
            </a>
       <div class="divider"></div>
        </div>
    <div class="col-xs-12 col-sm-offset-2  col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-0">
      <a href="/collections/accessories" class="banner zoom-in">
        <span class="figure">
          <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/womens.png?14209798005151405036" alt=""/>
          <span class="figcaption">
            <span class="block-table">
              <span class="block-table-cell">
                <span class="banner__title size40">Womens</span>
                <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
              </span>
            </span>
          </span>
        </span>
      </a>
      <div class="divider"></div>
      <a href="/collections/skate" class="banner zoom-in">
        <span class="figure">
          <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/footwear.png?14209798005151405036" alt=""/>
          <span class="figcaption">
            <span class="block-table">
              <span class="block-table-cell">
                <span class="banner__title size40">Footwear</span>
                <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
              </span>
            </span>
          </span>
        </span>
      </a>
    </div>
        <!-- /col-right -->
    </div>
    <div class="divider"></div>

</div>

1 个答案:

答案 0 :(得分:0)

似乎没有人试图解决它。我自己解决了。 这适用于那些寻找这样的网格系统的人。

将所有html替换为此

<div class="container" style="max-width:1300px;">               
<div class="row">
    <!-- col-left -->
      <div class="col-xs-12 col-sm-offset-2  col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-0">
        <a href="/collections/accessories" class="banner zoom-in">
    <span class="figure">
      <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/mens.png?14209798005151405036" alt=""/>
      <span class="figcaption">
        <span class="block-table">
          <span class="block-table-cell">
            <span class="banner__title size40">Mens</span>
            <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
          </span>
        </span>
      </span>
    </span>
  </a>
  <div class="divider"></div>
  <a href="/collections/skate" class="banner zoom-in">
    <span class="figure">
      <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/skates.png?14209798005151405036" alt=""/>
      <span class="figcaption">
        <span class="block-table">
          <span class="block-table-cell">
            <span class="banner__title size40">Skate</span>
            <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
          </span>
        </span>
      </span>
    </span>
  </a>
  <div class="divider"></div>
</div>
    <!-- /col-left -->
    <!-- col-right -->
    <div class="col-xs-12 col-sm-offset-2  col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-0">
        <a href="/collections/accessories" class="banner zoom-in">
            <span class="figure">
                <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/accessories_a2c62c03-a1fe-4b8d-96e3-0de1e87571bf.png?14209798005151405036" alt=""/>
                <span class="figcaption">
                    <span class="block-table">
                        <span class="block-table-cell">
                            <span class="banner__title size40">Accessories</span>
                            <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
                        </span>
                    </span>
                </span>
            </span>
        </a>
        <div class="divider"></div>
        <a href="/collections/skate" class="banner zoom-in">
            <span class="figure">
                <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/boardshorts.png?14209798005151405036" alt=""/>
                <span class="figcaption">
                    <span class="block-table">
                        <span class="block-table-cell">
                            <span class="banner__title size40">Boardshorts</span>
                            <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
                        </span>
                    </span>
                </span>
            </span>
        </a>
   <div class="divider"></div>
    </div>
<div class="col-xs-12 col-sm-offset-2  col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-0">
  <a href="/collections/accessories" class="banner zoom-in">
    <span class="figure">
      <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/womens.png?14209798005151405036" alt=""/>
      <span class="figcaption">
        <span class="block-table">
          <span class="block-table-cell">
            <span class="banner__title size40">Womens</span>
            <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
          </span>
        </span>
      </span>
    </span>
  </a>
  <div class="divider"></div>
  <a href="/collections/skate" class="banner zoom-in">
    <span class="figure">
      <img src="https://cdn.shopify.com/s/files/1/1299/2659/files/footwear.png?14209798005151405036" alt=""/>
      <span class="figcaption">
        <span class="block-table">
          <span class="block-table-cell">
            <span class="banner__title size40">Footwear</span>
            <span class="btn btn--ys btn--xl banner_btn">Shop now!</span>
          </span>
        </span>
      </span>
    </span>
  </a>
</div>
    <!-- /col-right -->
</div>
<div class="divider"></div>