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

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="c5-banner__section">
<div class="c5-section">
  <div class="c5-banner__wrap">
    <div class="c5-banner__inner js-banner1">
      <div class="c5-banner__content">
        <p>Content 1</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 2</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 3</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 4</p>
      </div>
      <!-- /.c5-banner__content -->
      
      <div class="c5-banner__content">
        <p>Content 5</p>
      </div>
      <!-- /.c5-banner__content -->

    </div>
    <!-- /.c5-banner__inner -->
    <div class="c5-banner__more-btn js-btn1">もっと見る</div>
    <!-- /.c5-banner__more-btn -->
  </div>
  <!-- /.c5-banner__wrap -->

  <div class="c5-banner__wrap">
    <div class="c5-banner__inner js-banner2">
      <div class="c5-banner__content">
        <p>Content 1</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 2</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 3</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 4</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 5</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 6</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 7</p>
      </div>
      <!-- /.c5-banner__content -->

      <div class="c5-banner__content">
        <p>Content 8</p>
      </div>
      <!-- /.c5-banner__content -->

    </div>
    <!-- /.c5-banner__inner -->
    <div class="c5-banner__more-btn js-btn2">もっと見る</div>
    <!-- /.c5-banner__more-btn -->
  </div>
  <!-- /.c5-banner__wrap -->
</div>
<!-- /.c5-section -->
</div>
<!-- /.c5-banner__section -->
              
            
!

CSS

              
                @charset "UTF-8";

body{
  *{
    box-sizing: border-box;
  }
}
.c5-banner__more-btn{
  width: 130px;
  height: 40px;
  line-height: 40px;
  background-color: #333;
  margin: 20px auto 0;
  padding-left: 10px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  position: relative;
  &:hover{
    color: #fff;
    opacity: .7;
    cursor: pointer;
  }
  &::before{
    display: block;
    content: '';
    width: 15px;
    height: 15px;
    background: url('https://dl.dropbox.com/s/gg7r7p629whczlm/icn_plus.png?dl=0') no-repeat 0 0;
    background-size: contain;
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
  }
}

.c5-banner__more-btn.is-show{
  &::before{
    background: url('https://dl.dropbox.com/s/8p5v4golyi39u8n/icn_minus.png?dl=0') no-repeat 0 0;
    background-size: contain;
  }
}

@media screen and (min-width:750px){
  .c5-banner__more-btn{
    width: 210px;
    height: 50px;
    line-height: 50px;
    margin: 30px auto 0;
    font-size: 18px;
    &::before{
      width: 26px;
      height: 26px;
      left: 18px;
    }
  }
}

.c5-banner__section{
  margin: 0 auto 50px;
  padding: 20px;
  background-color: #ebebeb;
}

.c5-section{
  max-width: 1200px;
  margin: 0 auto;
  .c5-banner{
    &__wrap{
      &:first-of-type{
        margin-bottom: 35px;
      }
    }
    &__content{
      width: 100%;
      background-color: #fff;
      margin-bottom: 15px;
      padding: 5px;
      position: relative;
      p{
        text-align: center;
      }
    }
  }
}



@media screen and (min-width:750px){
  .c5-banner__section{
    margin-bottom: 100px;
    padding: 40px 15px 50px;
  }
  .c5-section{
    .c5-banner{
      &__wrap{
        &:first-of-type{
          margin-bottom: 80px;
        }
      }
      &__inner{
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
      }
      &__content{
        width: 32.8%;
        max-width: 393px;
        margin-bottom: 10px;
        padding: 0;
        &:not(:nth-child(3n)){
          margin-right: 0.8%;
        }
      }
    }
  }
}

              
            
!

JS

              
                //もっと見るボタンがクリックされたら隠れてるコンテンツを表示する関数
function moreContents(Btn,Content){
    $(Btn).on('click ontouchEnd', function(){
      $(Content).slideToggle(200);
      $(this).toggleClass('is-show');

      if($(this).hasClass('is-show')){
        $(this).text('\u9589\u3058\u308b');//ボタンのテキストを「閉じる」に
      }else{
        $(this).text('\u3082\u3063\u3068\u898b\u308b');//ボタンのテキストを「もっと見る」に
      }

    });
  }

//1つ目のmoreボタン。コンテンツの4つ目以降を隠す
  var btn1 = '.js-btn1',
      content1 = '.js-more1',
      contentNum1 = $('.js-banner1 .c5-banner__content').length,//コンテンツの数を取得
      morenum1 = 3;
  //コンテンツが4つ以上だったらもっと見るボタンを表示
  if(contentNum1 > morenum1){
    //4つ目以降のコンテンツを隠す
    $('.js-banner1 .c5-banner__content:nth-child(n+' + (morenum1 + 1) + ')').addClass('js-more1').hide();
     moreContents(btn1,content1);

    }else{
      //コンテンツが3つ以下ならボタンを隠す
      $(btn1).hide();
    }

//2つ目のmoreボタン。コンテンツの7つ目以降を隠す
    var btn2 = '.js-btn2',
        content2 = '.js-more2',
        contentNum2 = $('.js-banner2 .c5-banner__content').length,//コンテンツの数を取得
        morenum2 = 6
    //コンテンツが7つ以上だったらもっと見るボタンを表示
    if(contentNum2 > morenum2){
      //7つ目以降のコンテンツを隠す
      $('.js-banner2 .c5-banner__content:nth-child(n+' + (morenum2 + 1) + ')').addClass('js-more2').hide();
       moreContents(btn2,content2);

    }else{
      //コンテンツが6つ以下ならボタンを隠す
      $(btn2).hide();
    }
              
            
!
999px

Console