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="row">
  <div class="col-xs-6 section section-default">
    <h2 class="text-center">Section 1</h1>
  </div>
  <div class="col-xs-6 section section-default">
    <h2 class="text-center">Section 2</h1>
  </div>
  <div class="col-xs-6 section section-default">
    <h2 class="text-center">Section 3</h1>
  </div>
  <div class="col-xs-6 section section-default">
    <h2 class="text-center">Section 4</h1>
  </div>
</div>

              
            
!

CSS

              
                /* ========================================
   Colors
   ======================================== */
// Background colors
$bgd-colors: #DC143C #1E90FF #6B8E23 #FFD700;
// Font-colors
$ft-color-default: rgb(51, 51, 51);
$ft-color-dimmed: rgb(131, 131, 131);

// Mixin to set the background-color
@mixin set-background($index) {
  background-color: nth($bgd-colors, $index);
}

// Mixin to set the 'dimmed' background-colors
@mixin set-background-dimmed($index) {
  background-color: lighten(desaturate(nth($bgd-colors, $index), 25), 18);
}

// Set the background-colors of the 'non-active' sections
@for $i from 1 through 4 {
  .section:nth-child(#{$i}) {
    @include set-background-dimmed($i);
  }
}

// Set the default background-colors of sections and the background-colors of 'active' sections
@for $i from 1 through 4 {
  .section:nth-child(#{$i}).section-height-expanded.section-active,
  .section:nth-child(#{$i}).section-default {
    @include set-background($i);
  }
}

/* ========================================
   Transitions, height and text color
   ======================================== */
.section {
  transition: height 0.5s ease-in-out, width 0.5s ease-in-out, background-color 0.5s ease-in-out;
  height: 50vh; /* See buggyfill/polyfill links on caniuse.com */
  color: $ft-color-default;
}

.section-height-collapsed {
  transition: height 0.5s ease-in-out, width 0.5s ease-in-out, background-color 0.5s ease-in-out, color 0.5s ease-in-out;
  height: 20vh;
  color: $ft-color-dimmed;
}

.section-height-expanded {
  transition: height 0.5s ease-in-out, width 0.5s ease-in-out, background-color 0.5s ease-in-out, color 0.5s ease-in-out;
  height: 80vh;
  color: $ft-color-dimmed;
}

/* ========================================
   Text color and shadow for the 'active' section
   ======================================== */
.section-active {
  color: $ft-color-default;
  z-index: 1;
  box-shadow: 0 0 3px 3px rgba(0,0,0,0.15);
}
              
            
!

JS

              
                $(document).ready(function() {
  // Define the different possible grid configurations
  // 'default' is for the onload page configuration
  // 'first', 'second', etc.  refer to the index of the 'active' section in the grid.
  var gridConfigurations = {
    default: [{w:6,h:'default'},{w:6,h:'default'},{w:6,h:'default'},{w:6,h:'default'}],
    first: [{w:10,h:'height-expanded'},{w:2,h:'height-expanded'},{w:10,h:'height-collapsed'},{w:2,h:'height-collapsed'}],
    second: [{w:2,h:'height-expanded'},{w:10,h:'height-expanded'},{w:2,h:'height-collapsed'},{w:10,h:'height-collapsed'}],
    third: [{w:10,h:'height-collapsed'},{w:2,h:'height-collapsed'},{w:10,h:'height-expanded'},{w:2,h:'height-expanded'}],
    fourth: [{w:2,h:'height-collapsed'},{w:10,h:'height-collapsed'},{w:2,h:'height-expanded'},{w:10,h:'height-expanded'}]
  };
  // Define onClick behaviour
  $('.row').on('click', '.section', function() {
    var index = $(this).index();
    switch (index) {
      case 0:
        modifyGrid(gridConfigurations.first);
        break;
      case 1:
        modifyGrid(gridConfigurations.second);
        break;
      case 2:
        modifyGrid(gridConfigurations.third);
        break;
      case 3:
         modifyGrid(gridConfigurations.fourth);
        break;
    }
    $(this).addClass('section-active');
  })
});

// 'modifyGrid' modifies the grid so that it matches the configuration passed as an argument
function modifyGrid(gridConfigArray) {
  $('.section').each( function(index){
    $(this).removeClass("col-xs-6 col-xs-2 col-xs-10 section-default section-height-collapsed section-height-expanded section-active").addClass("col-xs-" + gridConfigArray[index].w + " section-" + gridConfigArray[index].h);
  })
}
              
            
!
999px

Console