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

              
                .header
  %h1 Latest posts
  %span.show-all#show-all
    Show all
    %span.show-all-count#show-all-count
  
.items#items
  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/1.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/2.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/3.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/4.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/5.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 
  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/1.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/2.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

  .item
    %img.item-image{:src => 'https://assets.iamsteve.me/placeholder/3.jpg'}
    %h2.item-title Lorem ipsum dolor sit
    %p.item-description Lorem ipsum dolor sit amet. Elit consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              
            
!

CSS

              
                $color-one: #f1fafb;
$color-two: #876a96;
$color-three: #d7c1e0;

// Font stack
$system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

body {
  background: $color-one;
  padding: 36px 0;
  font-family: $system;
  line-height: 1.5; }

// Show all adjustments
.items-columns .item {
  flex: 1 1 20%;
  margin-bottom: 24px;
  
  @media (max-width: 799px) {
    flex-basis: 30%; }

  @media (max-width: 539px) {
    flex-basis: 50%; } }

// Flickity adjustments
.flickity-enabled.items {
  display: block;
  margin: 0 -24px; }

.flickity-viewport {
  margin: 0 24px; }

.flickity-enabled.items .item {
  width: 25%;
  
  @media (max-width: 539px) {
    width: 30%; }
  
  @media (max-width: 539px) {
    width: 48%; } }

// Items wrapper styles
.items {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar;
  padding: 12px 24px 24px; }

.items-columns {
  flex-flow: row wrap;
  margin-bottom: -24px;
  padding-right: 0; }

// Item basic styles
.item {
  background: #fff;
  border-radius: 8px;
  box-shadow: 
    0 1px 1px rgba(#29435C, .2),
    0 6px 12px -6px rgba(#29435C, .4);
  
  flex: 0 0 280px;
  margin-right: 24px; }

.item-image {
  display: block;
  width: 100%;
  height: 40vh;
  max-width: 100%;
  max-height: 196px;
  object-fit: cover;
  border-radius: 8px 8px 0 0; }

.item-title {
  font-size: 16px;
  color: #666;
  margin: 0 0 6px;
  padding: 24px 24px 0; }

.item-description {
  font-size: 14px;
  margin: 0;
  padding: 0 24px 24px;
  color: #999; }

.header {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-content: center;
  align-items: center;
  padding: 12px 24px;
  
  h1 {
    margin: 0;
    font-weight: 700;
    font-size: 21px;
    color: $color-two; } }

.show-all {
  font-size: 14px;
  font-weight: 700;
  color: $color-two;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: .2s; }

.active {
  background: $color-two;
  color: $color-three; }

/*! Flickity v1.1.1
https://flickity.metafizzy.co
---------------------------------------------- */
.flickity-enabled {
  position: relative; }

.flickity-enabled:focus { 
  outline: none; }

.flickity-viewport {
  position: relative;
  height: 100%; }

.flickity-slider {
  position: absolute;
  width: 100%;
  height: 100%; }

/* Draggable */
.flickity-enabled.is-draggable {
  -webkit-tap-highlight-color: transparent;
          tap-highlight-color: transparent;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none; }

.flickity-enabled.is-draggable .flickity-viewport {
  cursor: move;
  cursor: -webkit-grab;
  cursor: grab; }

.flickity-enabled.is-draggable .flickity-viewport.is-pointer-down {
  cursor: -webkit-grabbing;
  cursor: grabbing; }
              
            
!

JS

              
                function is_touch_device()
{
  // Checks for existence in all browsers and IE 10/11 & Surface
  return 'ontouchstart' in window || navigator.maxTouchPoints;
}

var all = document.getElementById('show-all');
var items = document.getElementById('items');

// Add value to counter
var count = items.children.length;
var counter = document.getElementById('show-all-count');
counter.innerText = ' (' + count + ')';

// Flickity related
if (!is_touch_device())
{
  var options = {
    cellAlign: 'left',
    freeScroll: true,
    prevNextButtons: false,
    pageDots: false,
    contain: true
  };
  var isFlickity = true;
  var flickity = new Flickity(items, options);
}

// Toggle active states and flickity
all.addEventListener('click', function() {
  this.classList.toggle('active');
  items.classList.toggle('items-columns');
  
  if (!is_touch_device())
  {
    if (isFlickity) flickity.destroy();
    else flickity = new Flickity(items, options);

    isFlickity = !isFlickity;
  }
});
              
            
!
999px

Console