Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>掉一格範例</h2>
<div class="list-wrap sample-bad">
  <ul class="list">
    <li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      非少能高
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      轉今喜能東了油我交去動張
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少一也物紙國部願改求後
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li>
  </ul>
</div>
<hr>
<h2>table 解</h2>
<div class="list-wrap sample-table">
  <ul class="list">
    <li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      非少能高
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      轉今喜能東了油我交去動張
    </li></ul>
   <ul class="list"><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少一也物紙國部願改求後
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li></ul>
   <ul class="list"><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li>
  </ul>
</div>
<hr>
<h2>固定高度解</h2>
<div class="list-wrap sample-fixheight">
  <ul class="list">
    <li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      非少能高
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      轉今喜能東了油我交去動張
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少一也物紙國部願改求後
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li>
  </ul>
</div>
<hr>
<h2>display:flex解</h2>
<div class="list-wrap sample-flex">
  <ul class="list">
    <li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      非少能高
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      轉今喜能東了油我交去動張
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少一也物紙國部願改求後
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li>
  </ul>
</div>
<hr>
<h2>display:grid 解<small>(如沒有顯示成一排三個,請確認您的<a href="http://caniuse.com/#feat=css-grid" target="_blank">瀏覽器版本</a>)是否支援 css grid</small></h2>
<div class="list-wrap sample-grid">
  <ul class="list">
    <li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      非少能高
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      轉今喜能東了油我交去動張
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少一也物紙國部願改求後
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li>
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li>
  </ul>
</div>

<hr>
<h2>waterfall layout 解(以Masonry為例)</h2>
<div class="list-wrap sample-masonry">
  <ul class="list masonry-list">
    <li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      非少能高
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      轉今喜能東了油我交去動張
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少一也物紙國部願改求後
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦歐啦
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li><li class="item">
      <img src="https://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" class="pimg">
      少還心定每地子行以
    </li>
  </ul>
</div>
<hr>
貓圖片來自寬高參數突然故障的 <a href="https://placekitten.com/" target="_blank">placekitten</a>
              
            
!

CSS

              
                *{box-sizing:border-box}
.list-wrap{width:300px;}
.list{padding:0;margin:0;list-style:none;overflow:hidden}
.pimg{display:block;max-width:100%}
.list>li{width:31.3%;float:left;margin:1% 1% 1% 0}

.sample-table{display:table}
.sample-table>.list{display:table-row}
.sample-table>.list>li{display:table-cell;float:none;padding:1%}

.sample-fixheight>.list>li{height:130px}

.sample-flex>.list{
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}
.sample-flex>.list>li{
    float:none;
}

.sample-grid>.list{
    display: grid; 
    grid-template-columns: 33% 33% 33%; 
    grid-gap: 10px;
}
.sample-grid>.list>li{
    float:none;width:auto;marign:0  
}
 
.masonry-list{
  width:390px
}
.masonry-list:after{
  content: '';
  display: block;
  clear: both;
}
.masonry-list>li{
  width: 110px;
  float: left;margin:0 0 10px;
}


              
            
!

JS

              
                $(function(){
  $('.masonry-list').masonry({
    itemSelector: '.item',
    columnWidth: 110,
    gutter: 10
  });
})

              
            
!
999px

Console