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="wrapper">
		  <section class="how-to">
			    <h2>mix-blend-mode Demo &ndash; 
				      <span>How To</span>
    			</h2>
			    <div class="info">
				      <h3>Color Buttons</h3>
				      <p>
					        You can change the page background color by clicking one of the color buttons at the top.  
				      </p>
				      <p>
					        Click the Reset button to go back to the original background color.
      				</p>
				      <p>
					        The image will be blended with the chosen page background color.
				      </p>
				
				      <h3>Blend Modes</h3>
      				<p>
					        You can select blend modes for the image from the select box.  The default is <strong>Normal</strong>, which doesn't apply any blend mode.
				       </p>
				      <p>
					        Once you select a blend mode, the image blends with the page background color according to the selected blend mode.
				      </p>
				
				      <h3>Isolation</h3>
				      <p>
					        By checking the <strong>Isolate</strong> box, the image will cease blending with the page background color.  It now constitutes a separate <strong>stacking context</strong> with respect to the background.
				      </p>
			    </div>
		  </section>
		
		  <div class="colors">
			    <ul>
				      <li>
        <button type="button" value="yellow">Yellow
        </button>
      </li>
				      <li>
        <button type="button" value="red">Red
        </button>
      </li>
				      <li>
        <button type="button" value="blue">Blue
        </button>
      </li>
				      <li>
        <button type="button" value="green">Green
        </button>
      </li>
				      <li>
        <button type="button" value="gainsboro">Reset
        </button>
      </li>
			    </ul>
		  </div><!--/.colors -->
		
		  <div class="controls">
			    <select>
    <option value="normal">Normal</option>
    <option value="multiply">Multiply</option>
    <option value="screen">Screen</option>
    <option value="overlay">Overlay</option>
    <option value="darken">Darken</option>
    <option value="lighten">Lighten</option>
				    <option value="color-dodge">Color Dodge</option>
				    <option value="color-burn">Color Burn</option>
				    <option value="hard-light">Hard Light</option>
				    <option value="soft-light">Soft Light</option>
				    <option value="difference">Difference</option>
				    <option value="exclusion">Exclusion</option>
				    <option value="hue">Hue</option>
				    <option value="saturation">Saturation</option>
				    <option value="color">Color</option>
				    <option value="luminosity">Luminosity</option>
			    </select>
		
			    <label for="isolate">
      				<input type="checkbox" id="isolate" value=""> Isolate
			    </label>
		  </div><!--/.controls -->
	
		  <div class="box">
			    <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/source.jpg" alt="">
			    <h2>Cityscape</h2>
		  </div><!--/.box -->
		
	</div><!--/.wrapper -->
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,900);
* {
	box-sizing: border-box;
}

body {
	background-color: gainsboro;
	color: #666;
	font-size: 1.5em;
	font-family: 'Source Sans Pro', Arial, sans-serif;
	font-weight: 300;
}

.wrapper {
	max-width: 960px;
	margin: 0 auto;
	padding-bottom: 4em;
}

.how-to {
	background-color: #fff;
	border: 1px solid #ccc;
	cursor: pointer;
	font-size: .6em;
	max-width: 300px;
	padding: 0 1em;
	margin: 0 auto;
	overflow-y: hidden;
	z-index: 3;
	transition: background 1s linear;
}

.how-to h2,
.how-to h3 {
	text-align: center;
	font-weight: 400;
}

.how-to h2 {
	margin-bottom: -.5em;
	margin-top: .3em;
	font-weight: 900;
}

.how-to:hover {
	background-color: #d2d7d3;
	border-color: #95a5a6;
}

.how-to h2 span {
	display: block;
	font-weight: 400;
}

.info {
	height: 0;
	opacity: 0;
	transition: height 1s ease-in, opacity 1s ease-in;
}

.how-to.open {
	overflow-y: auto;
}

.how-to.open:hover {
	background-color: #fff;
}

.how-to.open .info {
	opacity: 1;
	height: 200px;
}

.colors {
   margin-top: 1.3em;
}

.colors > ul {
	list-style-type: none;
	text-align: center;
	padding-left: .6em;
}

.colors li {
	display: inline-block;
	margin-right: .5em;
	margin-bottom: .5em;
}

button {
	border-radius: 50%;
	color: #555;
  font-size: .5em;
	font-weight: 700;
	cursor: pointer;
	padding: 1em;
	text-transform: uppercase;
	width: 6em;
	height: 6em;
}

button:focus,
button:hover {
	outline: none;
  border: 2px solid #333;
}

li:first-child button {
	background-color: yellow;
}

li:nth-child(2) button {
	background-color: red;
}

li:nth-child(3) button {
	background-color: royalBlue;
}

li:nth-child(4) button {
	background-color: lightGreen;
}

.box {
	text-align: center;
	margin: 1em auto;
	padding: 0;
	width: 100%;
	max-width: 600px;
	position: relative;
}

.box img {
	max-width: 100%;
	height: auto;
}

.box h2 {
	position: absolute;
	bottom: 1em;
	right: 3%;
	color: white;
	text-align: center;
	font-size: 1.5em;
	font-weight: 900;
	max-width: 60%;
	margin-top: 5em;
	background-color: red;
	padding: .5em .25em;
	transform: rotate(-20deg);
	mix-blend-mode: difference;
}

.controls {
	max-width: 800px;
	margin: 0 auto;
  padding-bottom: 1em;
	text-align: center;
}

select {
	color: #555;
	font-size: 1em;
	height: 1.5em;
	padding: 0 .3em;
	width: 50%;
}

label {
	display: inline-block;
	font-size: 1.1em;
}
              
            
!

JS

              
                (function( $ ) {
	//Toggle help box at the top 
	var $helpBox = $('.how-to');
	$helpBox.on('click', function() {
		var $this = $(this);
		$this.toggleClass('open');
    
    //scroll to the top of the help box when closing it 
		if(!$this.hasClass('open')) {
			$this.animate({
				scrollTop: 0 
			}, 1000);
		}
	});
	
	//Change body background color 
	var $buttons = $('button');
	
	$buttons.on('click', function() {
		var $this = $(this),
			$btnVal = $this.val();
		$('body').css('background-color', $btnVal);
	});
	
	//Add mix-blend-mode to the image using the select box 
	var $select = $('select'),
		$selectVal = $select.val(),
		$img = $('img');
	
	//... on page load 
	$img.css('mix-blend-mode', $selectVal); 
	
	//... and as user makes selection from select box 
	$select.on('change', function() {
		var $this = $(this);
		$selectVal = $this.val();
		$img.css('mix-blend-mode', $selectVal);
	});
	
	//Toggle the isolation property on the image container via the checkbox 
	var $checkIsolate = $('#isolate'),
		$imgContainer = $('.box');
	
	$checkIsolate.on('change', function() {
		var $this = $(this);
		if($this.is(':checked') ) {
			$imgContainer.css('isolation', 'isolate');
		} else {
			$imgContainer.css('isolation', 'auto');
		}
	});
})(jQuery);
              
            
!
999px

Console