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 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

              
                <ul class="list">
  <li class="target">target 1</li>
  <li class="target">target 2</li>
  <li class="target">target 3</li>
  <li class="target">target 4</li>
  <li class="target">target 5</li>
  <li class="target">target 6</li>
  <li class="target">target 7</li>
  <li class="target">target 8</li>
  <li class="target">target 9</li>
  <li class="target">target 10</li>
  <li class="target">target 11</li>
  <li class="target">target 12</li>
  <li class="target">target 13</li>
  <li class="target">target 14</li>
  <li class="target">target 15</li>
  <li class="target">target 16</li>
  <li class="target">target 17</li>
  <li class="target">target 18</li>
</ul>

<button class="btn-more">もっと見る</button>
              
            
!

CSS

              
                ul,li {
  margin: 0;
  padding: 0;
  list-style: none;
}
button {
  outline: none;
  border: none;
}
.list {
  display: flex;
  flex-wrap: wrap;
  max-width: 660px;
  margin: 0 auto;
}
.target {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 50px;
  margin: 10px;
  background: #828E98;
  color: #fff;
  
  &.is-hidden {
    display: none;
    opacity: 0;
  }
  &.is-show {
    animation: fadeIn 1s ease;
  }
}
.btn-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 50px;
  margin: 20px auto;
  border-radius: 25px;
  background: #AA987F;
  color: #fff;
  font-weight: bold;
  
  &:hover {
    opacity: .9
  }
}

@keyframes fadeIn {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
     transform: translateY(0);
    opacity: 1;
  }
}
              
            
!

JS

              
                var showNum = 6, // 最初に表示しておく件数
    addNum = 3,  // クリックごとに表示したい件数
    target = '.target',
    btn = $('.btn-more');

$(target).removeClass('is-show');

$(target + ':nth-child(n + ' + (showNum + 1) + ')').addClass('is-hidden');

btn.on('click', function () {
  $(target + '.is-hidden').slice(0, addNum).removeClass('is-hidden').addClass('is-show');
  
  if ($(target + '.is-hidden').length == 0) {
    btn.fadeOut();
  }
});

              
            
!
999px

Console