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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="container">
  <h3>オフセット(offset)でボタンを中央寄せ</h3>
  <br>
  <div class="row">
    <div class="col-sm-4 col-sm-offset-4">
      <a href="#" class="btn btn-primary btn-block">Button</a>
    </div>
  </div>

  <hr style="margin: 40px 0;">

  <h3>カラムを入れ子(ネスト)にする</h3>
  <br>
  <div class="row">
    <div class="col-sm-6">
      col-sm-6
      <div class="row">
        <div class="col-sm-4">col-sm-4</div>
        <div class="col-sm-4">col-sm-4</div>
        <div class="col-sm-4">col-sm-4</div>
      </div>
    </div>
    <div class="col-sm-6">
      col-sm-6
      <div class="row">
        <div class="col-xs-6">col-xs-6</div>
        <div class="col-xs-6">col-xs-6</div>
      </div>
    </div>
  </div>

  <hr style="margin: 40px 0;">

  <h3>カラムの表示順序を入れ替える</h3>
  <br>
  <!-- このままだと左サイドバーが上になる -->
  <div class="row">
    <div class="col-sm-3">左サイドバー</div>
    <div class="col-sm-9">メインコンテンツ</div>
  </div>

  <hr style="margin: 20px 0;">

  <!-- サイドバーは右に表示される -->
  <div class="row">
    <div class="col-sm-9">メインコンテンツ</div>
    <div class="col-sm-3">左サイドバー</div>
  </div>

  <hr style="margin: 20px 0;">

  <!-- pushで押し出し、pullで引っ張る -->
  <div class="row">
    <div class="col-sm-9 col-sm-push-3">メインコンテンツ(col-sm-push-3)</div>
    <div class="col-sm-3 col-sm-pull-9">左サイドバー(col-sm-pull-9)</div>
  </div>

  <hr style="margin: 40px 0;">

  <h3>高さの違うカラムでも正しく改行する</h3>
  <br>
  <div class="row">
    <div class="col-xs-4" style="height:100px;">高さ100px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>

    <div class="col-xs-4" style="height:100px;">高さ100px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>
  </div>

  <hr style="margin: 20px 0;">

  <div class="row">
    <div class="col-xs-4" style="height:100px;">高さ100px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>

    <!-- 改行 -->
    <span class="clearfix"></span>

    <div class="col-xs-4" style="height:100px;">高さ100px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>
    <div class="col-xs-4" style="height:50px">高さ50px</div>
  </div>

  <hr style="margin: 20px 0;">
</div>
              
            
!

CSS

              
                .row > div{
  text-align: center;
  padding-top: 15px;
  padding-bottom: 15px;
  /*margin-bottom: 15px;*/
}
.row > div:nth-child(even){
  background-color: #ccc;
}
.row > div:nth-child(odd){
  background-color: #eee;
}
.row .row > div:nth-child(odd){
  background-color: #ccc;
}
              
            
!

JS

              
                
              
            
!
999px

Console