Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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="caption">サンプル</div>	
<div id="table">
	<div class="header-row row">
    <span class="cell primary">年</span>
    <span class="cell">名前</span>
     <span class="cell">色</span>
    <span class="cell">大きさ</span>
    <span class="cell">金額</span>
  </div>
  <div class="row">
	<input type="radio" name="expand">
    <span class="cell primary" data-label="年">2013年</span>
    <span class="cell" data-label="名前">りんご</span>
     <span class="cell" data-label="色">赤</span>
     <span class="cell" data-label="大きさ">普通</span>
    <span class="cell" data-label="金額">100円</span>
  </div>
  <div class="row">
	<input type="radio" name="expand">
    <span class="cell primary" data-label="年">2014年</span>
    <span class="cell" data-label="名前">すいか</span>
     <span class="cell" data-label="色">緑</span>
     <span class="cell" data-label="大きさ">でかい</span>
     <span class="cell" data-label="金額">1000円</span>
  </div>
  <div class="row">
	<input type="radio" name="expand">
    <span class="cell primary" data-label="年">2015年</span>
    <span class="cell" data-label="名前">みかん</span>
     <span class="cell" data-label="色">オレンジ</span>
     <span class="cell" data-label="大きさ">小さめ</span>
     <span class="cell" data-label="金額">40円</span>
  </div>
  <div class="row">
	<input type="radio" name="expand">
    <span class="cell primary" data-label="年">2016年</span>
    <span class="cell" data-label="名前">いちご</span>
     <span class="cell" data-label="色">赤</span>
     <span class="cell" data-label="大きさ">小さい</span>
     <span class="cell" data-label="金額">500円</span>
  </div>
  <div class="row">
	<input type="radio" name="expand">
    <span class="cell primary" data-label="年">2017年</span>
    <span class="cell" data-label="名前r">マンゴー</span>
     <span class="cell" data-label="色">黄色</span>
     <span class="cell" data-label="大きさ">中くらい</span>
     <span class="cell" data-label="金額">1万円</span>
  </div>
  <div class="row">
	<input type="radio" name="expand">
    <span class="cell primary" data-label="年">2018年</span>
    <span class="cell" data-label="名前">もも</span>
     <span class="cell" data-label="色">ピンク</span>
     <span class="cell" data-label="大きさ">普通</span>
     <span class="cell" data-label="金額">1500円</span>
  </div>
</div>

              
            
!

CSS

              
                body {
  background: #cacaca;
  margin: 0;
  padding: 20px;
  font-weight: 300;
}

#table {
  display: table;
  width: 100%;
  background: #fff;
  margin: 0;
  box-sizing: border-box;
}

.caption {
  display: block;
  width: 100%;
  background: yellow;
  height: 55px;
  padding-left: 10px;
  color: #111;
  font-size: 20px;
  line-height: 55px;
  box-sizing: border-box;
}

.header-row {
  background: #8b8b8b;
  color: #fff;
}

.row {
  display: table-row;
}

.cell {
  display: table-cell;
  padding: 6px;
  border-bottom: 1px solid #e5e5e5;
  text-align: center;
}

.primary {
  text-align: left;
}

input[type="radio"],
input[type="checkbox"] {
  display: none;
}

@media only screen and (max-width: 760px) {
  body {
    padding: 0;
  }

  #table {
    display: block;
    margin: 44px 0 0 0;
  }

  .caption {
    position: fixed;
    top: 0;
    text-align: center;
    height: 44px;
    line-height: 44px;
    z-index: 5;
    border-bottom: 2px solid #999;
  }

  .row {
    position: relative;
    display: block;
    border-bottom: 1px solid #ccc;
  }

  .header-row {
    display: none;
  }

  .cell {
    display: block;

    border: none;
    position: relative;
    height: 45px;
    line-height: 45px;
    text-align: left;
  }

  .primary:after {
    content: "";
    display: block;
    position: absolute;
    right: 20px;
    top: 18px;
    z-index: 2;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 10px solid #ccc;
  }

  .cell:nth-of-type(n + 2) {
    display: none;
  }

  input[type="radio"],
  input[type="checkbox"] {
    display: block;
    position: absolute;
    z-index: 1;
    width: 99%;
    height: 100%;
    opacity: 0;
  }

  input[type="radio"]:checked,
  input[type="checkbox"]:checked {
    z-index: -1;
  }

  input[type="radio"]:checked ~ .cell,
  input[type="checkbox"]:checked ~ .cell {
    display: block;

    border-bottom: 1px solid #eee;
  }

  input[type="radio"]:checked ~ .cell:nth-of-type(n + 2),
  input[type="checkbox"]:checked ~ .cell:nth-of-type(n + 2) {
    background: #e0e0e0;
  }

  input[type="radio"]:checked ~ .cell:nth-of-type(n + 2):before,
  input[type="checkbox"]:checked ~ .cell:nth-of-type(n + 2):before {
    content: attr(data-label);

    display: inline-block;
    width: 60px;
    background: #999;
    border-radius: 10px;
    height: 20px;
    margin-right: 10px;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    color: white;
  }

  input[type="radio"]:checked ~ .primary,
  input[type="checkbox"]:checked ~ .primary {
    border-bottom: 2px solid #999;
  }

  input[type="radio"]:checked ~ .primary:after,
  input[type="checkbox"]:checked ~ .primary:after {
    position: absolute;
    right: 18px;
    top: 22px;
    border-right: 10px solid transparent;
    border-left: 10px solid transparent;
    border-top: 10px solid #ccc;
    z-index: 2;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console