cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <h1>CSS Filters</h1>

<div id="gallery">
	
	<div id="blur">
		<h3>blur()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="10">
	</div>
	
	<div id="brightness">
		<h3>brightness()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="100">
	</div>
	
	<div id="contrast">
		<h3>contrast()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="1000">
	</div>
	
	<div id="grayscale">
		<h3>grayscale()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="0.1" min="0" max="1">
	</div>
	
	<div id="huerotate">
		<h3>hue-rotate()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="360">
	</div>
	
	<div id="invert">
		<h3>invert()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="100">
	</div>
	
	<div id="saturate">
		<h3>saturate()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="1000">
	</div>
	
	<div id="sepia">
		<h3>sepia()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="0.1" min="0" max="1">
	</div>
	
	<div id="opacity">
		<h3>opacity()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="0.1" min="0" max="1">
	</div>
	
	<div id="dropshadow">
		<h3>drop-shadow()</h3>
		<img src="http://lorempixel.com/200/150/">
		<input type="range" step="1" min="0" max="50">
	</div>

</div>
            
          
!
            
              body {
	padding: 20px;
	background: url(http://subtlepatterns2015.subtlepatterns.netdna-cdn.com/patterns/debut_dark.png);
}

h1 {
	color: #ECFF5E;
	text-align: center;
	font-size: 24px;
}

#gallery {
	width: 500px;
	margin: 10px auto;
}

#gallery div {
	width: 200px;
	float: left;
	margin: 0 40px 20px 0;
	padding: 15px;
	text-align: center;
	
	transition: background 0.5s ease;
}
#gallery div:nth-child(even) {
	margin-right: 0;
}

#gallery div:hover {
	background: rgba(0,0,0,0.3);
}

#gallery h3 {
	color: #DBDBDB;
	font-size: 16px;
}
#gallery div:hover h3 {
	color: #ECFF5E;
}

#gallery img {
	vertical-align: middle;
}

#gallery input {
	margin-top: 20px;
	width: 100%;
}

#gallery p {
	color: #fff;
	font-size: 12px;
}
            
          
!
            
              var $ = document.querySelector.bind(document);

// -- Blur --

$('#blur input').onchange = function() {
	var img = $('#blur img');
	img.style.webkitFilter = 'blur(' + this.value + 'px' + ')';
	
	var heading = $('#blur h3');
	heading.textContent = 'blur(' + this.value + 'px)';
};

// Set init val
$('#blur input').value = 2;
$('#blur input').onchange();


// -- Brightness --

$('#brightness input').onchange = function() {
	var img = $('#brightness img');
	img.style.webkitFilter = 'brightness(' + this.value + '%' + ')';
	
	var heading = $('#brightness h3');
	heading.textContent = 'brightness(' + this.value + '%)';
};

// Set init val
$('#brightness input').value = 30;
$('#brightness input').onchange();


// -- Contrast --

$('#contrast input').onchange = function() {
	var img = $('#contrast img');
	img.style.webkitFilter = 'contrast(' + this.value + '%' + ')';
	
	var heading = $('#contrast h3');
	heading.textContent = 'contrast(' + this.value + '%)';
};

// Set init val
$('#contrast input').value = 500;
$('#contrast input').onchange();


// -- GrayScale --

$('#grayscale input').onchange = function() {
	var img = $('#grayscale img');
	img.style.webkitFilter = 'grayscale(' + this.value + ')';
	
	var heading = $('#grayscale h3');
	heading.textContent = 'grayscale(' + this.value + ')';
};

// Set init val
$('#grayscale input').value = 0.7;
$('#grayscale input').onchange();


// -- Hue Rotate --

$('#huerotate input').onchange = function() {
	var img = $('#huerotate img');
	img.style.webkitFilter = 'hue-rotate(' + this.value + 'deg' + ')';
	
	var heading = $('#huerotate h3');
	heading.textContent = 'hue-rotate(' + this.value + 'deg' + ')';
};

// Set init val
$('#huerotate input').value = 120;
$('#huerotate input').onchange();


// -- Brightness --

$('#invert input').onchange = function() {
	var img = $('#invert img');
	img.style.webkitFilter = 'invert(' + this.value + '%' + ')';
	
	var heading = $('#invert h3');
	heading.textContent = 'invert(' + this.value + '%)';
};

// Set init val
$('#invert input').value = 20;
$('#invert input').onchange();


// -- Saturate --

$('#saturate input').onchange = function() {
	var img = $('#saturate img');
	img.style.webkitFilter = 'saturate(' + this.value + '%' + ')';
	
	var heading = $('#saturate h3');
	heading.textContent = 'saturate(' + this.value + '%)';
};

// Set init val
$('#saturate input').value = 300;
$('#saturate input').onchange();


// -- Sepia --

$('#sepia input').onchange = function() {
	var img = $('#sepia img');
	img.style.webkitFilter = 'sepia(' + this.value + ')';
	
	var heading = $('#sepia h3');
	heading.textContent = 'sepia(' + this.value + ')';
};

// Set init val
$('#sepia input').value = 0.6;
$('#sepia input').onchange();


// -- Opacity --

$('#opacity input').onchange = function() {
	var img = $('#opacity img');
	img.style.webkitFilter = 'opacity(' + this.value + ')';
	
	var heading = $('#opacity h3');
	heading.textContent = 'opacity(' + this.value + ')';
};

// Set init val
$('#opacity input').value = 0.4;
$('#opacity input').onchange();


// -- Drop Shadow --

$('#dropshadow input').onchange = function() {
	var img = $('#dropshadow img');
	img.style.webkitFilter = 'drop-shadow(' + this.value + 'px ' + this.value + 'px 15px white)';
	
	var heading = $('#dropshadow h3');
	heading.textContent = 'drop-shadow(' + this.value + 'px ' + this.value + 'px 15px white)';
};

// Set init val
$('#dropshadow input').value = 5;
$('#dropshadow input').onchange();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console