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="tab inner layout">
  <div class="tab__layout">
    <!-- 1つ目のタブとコンテンツ -->
    <label class="tab__button">
      <input type="radio" name="tab-2" checked>
      <p>タブ1</p>
    </label>
    <div class="tab__content">
      <p>1つ目のコンテンツ部分になります。</p>
    </div>

    <!-- 2つ目のタブとコンテンツ -->
    <label class="tab__button">
      <input type="radio" name="tab-2">
      <p>タブ2</p>
    </label>
    <div class="tab__content">
      <p>2つ目のコンテンツ部分になります。</p>
    </div>

    <!-- 3つ目のタブとコンテンツ -->
    <label class="tab__button">
        <input type="radio" name="tab-2">
        <p>タブ3</p>
    </label>
    <div class="tab__content">
      <p>3つ目のコンテンツ部分になります。</p>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /* リセットCSS */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* インナーとレイアウト調整 */
.inner {
  max-width: calc(1000px + 50px * 2);
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: 50px;
  padding-left: 50px;

  @media screen and (max-width: 767px) {
    padding-right: 30px;
    padding-left: 30px;
  }

  @media screen and (max-width: 600px) {
    padding-right: 20px;
    padding-left: 20px;
  }
}

.layout {
  margin-top: 100px;
}

/* タブ切り替えで使用するCSS */
.tab__layout {
  display: flex;
  flex-wrap: wrap;
  column-gap: 10px;


  &::after {
    content: '';
    display: block;
    width: 100%;
    height: 3px;
    background: #5CC0EF;
    order: -1;
  }
}

.tab__button {
  cursor: pointer;
  padding: 16px 20px;
  border-radius: 5px 5px 0 0;
  background-color: #ccc;
  color: #fff;
  text-align: center;
  transition: all 0.3s;
  //これがないと横並びにならない
  order: -1;
  //これがないとボタンの幅が均等にならない
  flex: 1 1;

  &:hover {
    opacity: 0.7;
  }

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

// アクティブなボタン
.tab__button:has(:checked) {
  cursor: default;
  background-color: #5CC0EF;

  &:hover {
    opacity: 1;
  }
}

.tab__content {
  width: 100%;
  height: 0;
  overflow: hidden;
  opacity: 0;
}

.tab__button:has(:checked) + .tab__content {
  height: auto;
  overflow: auto;
  opacity: 1;
  transition: .5s opacity;
  padding: 20px;
  border-top: none;
}


              
            
!

JS

              
                
              
            
!
999px

Console