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

              
                <div class="hero">
  <div class="hero__image" style="background-image:url('https://source.unsplash.com/1800x600/?forest');"></div>
    <div class="hero__blend-colour"></div>
</div>

<div class="container">
  <div class="card_container">
    
     <div class="card">
        <div class="card__blend-colour">
          <img src="https://source.unsplash.com/900x600/?mountain" class="card__image" alt="Mountain">
        </div>
        <div class="card__content">
          <span>Standard image, no transition</span>
        </div>
    </div>

    <div class="card">
      <div class="card__blend-colour card__image--transition">
        <img src="https://source.unsplash.com/900x600/?mountain" class="card__image card__image--transition" alt="Mountain">
      </div>
      <div class="card__content">
        <span>Standard image, with transition</span>
      </div>
    </div>

    <div class="card">
      <div class="card__blend-colour card__image--transition--long">
        <img src="https://source.unsplash.com/900x600/?mountain" class="card__image card__image--transition--long" alt="Mountain">
      </div>
      <div class="card__content">
        <span>Standard image, with long transition</span>
      </div>
    </div>


    <div class="card card--bg-img">
        <div class="card--bg-img__blend-colour"></div>
        <div class="card--bg-img__image" style="background-image:url('https://source.unsplash.com/900x600/?mountain');"></div>
        <div class="card__content">
          <span>Background image, no transition, colour above image.</span>
        </div>
    </div>

    <div class="card card--bg-img">
        <div class="card--bg-img__image card__image--transition" style="background-image:url('https://source.unsplash.com/900x600/?mountain');"></div>
        <div class="card--bg-img__blend-colour below card__image--transition"></div>
        <div class="card__content">
          <span>Background image, with transition, colour below image.</span>
        </div>
    </div>

    <div class="card card--bg-img">
        <div class="card--bg-img__blend-colour card__image--transition"></div> 
        <div class="card--bg-img__image card__image--transition" style="background-image:url('https://source.unsplash.com/900x600/?mountain');"></div>
        <div class="card__content">
          <span>Background image, with transition, colour above image.</span>
        </div>
    </div>

  </div>
</div>
              
            
!

CSS

              
                $blend_colour: springgreen;
$blend_mode: multiply;

body {
  margin: 0;
  font-family: Courier, serif;
  font-size: 14px;
}

.container {
  max-width: 1200px;
  margin: 0 auto 60px auto;
}

// ------------------------
// HERO
// ------------------------
.hero {
  position: relative;
  margin-bottom: 4vh;
  width: 100%;
  height: 40vh;
}

.hero__image { 
  height: 100%;
  width: 100%;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  filter: grayscale(100%);
  -webkit-filter: grayscale(100%);
  -moz-filter: grayscale(100%);
}

.hero__blend-colour {
  position: absolute;
  height: inherit;
  width: inherit;
  top: 0;
  left: 0;
  mix-blend-mode: $blend_mode;
  background-color: dodgerblue;
}

// ------------------------
// CARDS
// ------------------------
.card_container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.card {
  background-color: #FFFFFF;
  width: 30%;
  margin: 1%;
  float: left;
  overflow: hidden;
  position: relative;
  
    .card__content {
        padding: 5%;
        background-color: #EBEBEB;
    }
  
    &:focus,
    &:hover {
        // Change the blend colour
        .card__blend-colour,
        .card--bg-img__blend-colour {
            background-color: $blend_colour;
        }
        // Apply the grayscale and blend mode to the image
        .card__image,
        .card--bg-img__image {
            filter: grayscale(100%);
            -webkit-filter: grayscale(100%);
            -moz-filter: grayscale(100%);
            mix-blend-mode: $blend_mode;
        }
      
      cursor: pointer;
    }

}

// STANDARD IMAGE VARIANT
.card__image--bg {
    position: relative;
    margin-bottom: 10px;
    overflow: hidden; // Smoothens the animation in Safari
}

.card__image--transition {
    transition: 0.7s ease all;
    transition-delay: 0s;
    mix-blend-mode: $blend_mode;
}

.card__image--transition--long {
    transition: 3s ease all;
    transition-delay: 0s;
    mix-blend-mode: $blend_mode;
}

.card__image {
    display: block;
    width: 100%;
    height: auto;
    transform: translateZ(0); // Smoothens the animation in Chrome
}

// BACKGROUND IMAGE VARIANT
.card--bg_img {
    position: relative;
}

.card--bg-img__image,
.card--bg-img__blend-colour {
  height: 22vh;
  width: 100%;
}

.card--bg-img__image {
  background-repeat:no-repeat;
  background-size: cover;
}

.card--bg-img__blend-colour {
  position: absolute;
  top: 0;
  left: 0;
  
  &.below {
    mix-blend-mode: $blend_mode;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console