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

              
                <!--  カンプサイト: https://xd.adobe.com/spec/a8dd9e25-61c9-428f-5223-6b3171c83979-deec/ -->
<!-- 参考サイト https://flex-box.net/accordion/ -->

<body>
  <div id="accordion">
    <div class="accordion-container">
      <h4 class="article-title1">〇〇について</h4>
      <div class="accordion-content">
        <p>〇〇についての中身がぐいーんと出てくるイメージです。〇〇についての中身がぐいーんと出てくるイメージです。〇〇についての中身がぐいーんと出てくるイメージです。</p>
      </div><!--/.accordion-content-->
    </div>

    <div class="accordion-container">
      <h4 class="article-title2">〇〇について</h4>
      <div class="accordion-content">
        <p>〇〇についての中身がぐいーんと出てくるイメージです。〇〇についての中身がぐいーんと出てくるイメージです。〇〇についての中身がぐいーんと出てくるイメージです。</p>
      </div><!--/.accordion-content-->
    </div>

  </div><!--/#accordion-->
</body>
  
              
            
!

CSS

              
                @charset "utf-8";
//=====================
// 色の定義
$blue: #3F51B5;
$red: #E81919;
$black: #333333;
$yellow: #FEBB07;
$pink: #B53F6E;
$gray: #707070;
$bg: #EFEFEF;

// ================================
// mixin
// ================================
//media query
$tb: 980px; // tablet
$sp: 480px;  //smart phone

@mixin tb {
  @media (max-width: ($tb)) {
    @content;
  }
}

@mixin sp {
  @media (max-width: ($sp)) {
    @content;
  }
}

//====================
//style

#accordion {
  display: flex;
  width: 1366px;
  margin: 0 auto;
  justify-content: center;
  background: $bg;
  padding: 100px;
  
  @include tb {
    flex-direction: column;
  }
}

.accordion-container {
  position: relative;
  width: 444px;
  margin: 4px 4px;
  border-top: none;
  outline: 0;
  cursor: pointer;
  text-align: center;
   
  .article-title1, .article-title2 {
    display: block;
    position: relative;
    margin: 0;
    padding: 0.625em 0.625em 0.625em 2em;
    font-size: 1.25em;
    font-weight: normal;
    color: $blue;
    background: #fff;
    cursor: pointer;
    border: 1px solid $blue;
    border-radius: 30px;
  }
  
  .article-title1:hover,
  .article-title1:active,
  .content-entry.open .article-title1,
  .article-title2:hover,
  .article-title2:active,
  .content-entry.open .article-title2 {
    background-color: lighten($blue, 40%);
    color: $blue;
  }
  
  .article-title1:hover i:before,
  .article-title1:hover i:active,
  .article-title2:hover i:before,
  .article-title2:hover i:active,
  .content-entry.open i {
    color: $blue;
  }
}

.article-title1, .article-title2 {
  position: relative;
}

.article-title1:after,.article-title2:after {
  content: "";
  position: absolute;
  right: 25px;
  top: 38%;
  transition: all 0.2s ease-in-out;
  display: block;
  width: 8px;
  height: 8px;
  border-top: solid 2px #3F51B5;
  border-right: solid 2px #3F51B5;
  -webkit-transform: rotate(135deg);
  transform: rotate(135deg);
}

.article-title1.open:after, .article-title2.open:after {
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
  top: 45%;
}

.accordion-content {
  width: 300px;
  display: none;
  padding-left: 2.3125em;
  
  p {
    font-size: 16px;
    color: $blue;
    width: 388px;
    text-align: left;
  }
}

/* CSS for CodePen */
// .accordion-container {
//   width: 300px;
//   margin: 1.875em auto;
// }
              
            
!

JS

              
                jQuery(function ($) {
$('.article-title1').on('click', function () {
  /*クリックでコンテンツを開閉*/
  $(this).next().slideToggle(200);
  /*矢印の向きを変更*/
  $(this).toggleClass('open');
});
  
  $('.article-title2').on('click', function () {
  /*クリックでコンテンツを開閉*/
  $(this).next().slideToggle(200);
  /*矢印の向きを変更*/
  $(this).toggleClass('open');
});

});
              
            
!
999px

Console