Pen Settings



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


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


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.


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.


                <div id="contenedor">
<h1>CSS3 filters</h1>
<div class="rowDiv">

<div class="inputDiv">
<div id="originalImg"><img src="" alt="ametller"></div>
<div id="filterImg"><img src="" alt="ametller"></div> 

<input type="range" id="typeRange" value='65' min="0" max="100"  autocomplete="off">


<div class="radioDiv" id="control">

 <div class="rowDiv" id="Blur">
 <label><input type="radio" name="CSSfilter" value="Blur">blur</label>
 <input type="range" id="rangeBlur" class="plain" value='50' min="0" max="100"  autocomplete="off"  >
 <span id="BlurValue">5px</span>
 <div class="rowDiv" id="Brightness">
 <label><input type="radio" name="CSSfilter" value="Brightness">brightness</label>
 <input type="range" id="rangeBrightness" class="plain" value='15' min="0" max="100"  autocomplete="off"  >
 <span id="BrightnessValue">1.5</span>
 <div class="rowDiv" id="Contrast">
 <label><input type="radio" name="CSSfilter" value="Contrast">contrast</label>
 <input type="range" id="rangeContrast" class="plain" value='25' min="0" max="100"  autocomplete="off"  >
 <span id="ContrastValue">2.5</span>

 <div class="rowDiv" id="Grayscale">
 <label><input type="radio" name="CSSfilter" value="Grayscale" >grayscale</label>
 <input type="range" id="rangeGrayscale" class="plain" value='100' min="0" max="100"  autocomplete="off"  >
 <span id="GrayscaleValue">1</span>
 <div class="rowDiv" id="HueRotate">
 <label><input type="radio" name="CSSfilter" value="HueRotate" checked>hue-rotate</label>
 <input type="range" id="rangeHueRotate" class="plain" value='230' min="0" max="360"  autocomplete="off" >
 <span id="GrayscaleValue">180deg</span>
 <div class="rowDiv" id="Invert">
 <label><input type="radio" name="CSSfilter" value="Invert">invert</label>
 <input type="range" id="rangeInvert" class="plain" value='100' min="0" max="100"  autocomplete="off"  >
 <span id="InvertValue">1</span></div>
 <div class="rowDiv" id="Saturate">
 <label><input type="radio" name="CSSfilter" value="Saturate">saturate</label>
 <input type="range" id="rangeSaturate" class="plain" value='30' min="0" max="100"  autocomplete="off"  >
 <span id="SaturateValue">3</span>
 <div class="rowDiv" id="Sepia">
 <label><input type="radio" name="CSSfilter" value="Sepia" >sepia</label>
 <input type="range" id="rangeSepia" class="plain" value='100' min="0" max="100" autocomplete="off" >
 <span id="SepiaValue">1</span>
 <p>Comparaci&oacute;n entre una imagen con filtro CSS y la imagen original.
Arrastre el limite entre las dos im&aacute;genes para ver la diferencia.</p> 


                @import url(;
/* 1 */
*{ box-sizing:border-box; margin:0; padding:0; color:white; font-size:16px; font-family:"Quattrocento Sans", sans-serif; -webkit-font-smoothing: antialiased;}
html,body{  height:100%; background-color:#333;}
	-webkit-flex-direction : column;
    -ms-flex-direction : column;
    flex-direction : column;
	margin:50px auto;
	-webkit-flex-direction : row;
    -ms-flex-direction : row;
    flex-direction : row;
#control label{  display:inline-block; width:25%; height:2em;}
#control [type=range]:disabled{ opacity:.4;}

	-webkit-flex-direction : column;
    -ms-flex-direction : column;
    flex-direction : column;
	-webkit-justify-content: space-between;
	-ms-flex-pack: justify;
	justify-content: space-between;

input[type=radio]{ margin:.25em 1em .25em 0;}
#control{ width:640px; padding-top:2em;}
#contenedor h1{ font-size:180%; width:100%; text-align:center; margin:1em 0;}

.inputDiv{ width:640px; height:480px;position:relative; overflow:hidden;}
.inputDiv div{ position:absolute;overflow:hidden} 
.inputDiv #typeRange{ position:absolute; bottom:0px;} 

#filterImg img{
#filterImg{ width:calc(640px * .65); border-right:10px solid rgba(0,0,0,.3)}
#typeRange{ display:block; width:640px; height:480px; background-color:transparent}
#typeRange:focus {
  outline: none;
/* 2 */
#typeRange, #typeRange::-webkit-slider-runnable-track, #typeRange::-webkit-slider-thumb {
  -webkit-appearance: none; 
#typeRange, #typeRange::-moz-range-thumb, #typeRange::-moz-range-thumb {
  -moz-appearance: none; position:relative;

/* 2.1 THUMB */
#typeRange::-webkit-slider-thumb{ height:480px; width:15px;  background-color:transparent; cursor: col-resize;}
#typeRange::-moz-range-thumb{ height:480px; width:15px;  background-color:transparent;  cursor: col-resize; border:none;}
#typeRange::-ms-thumb{ height:480px; width:15px;  background-color:transparent;  cursor: col-resize;}

/* 2.2 TRACK */

#typeRange::-webkit-slider-runnable-track{height:480px; background:transparent;}
#typeRange:focus::-webkit-slider-runnable-track{outline: none;}

#typeRange::-moz-range-track{outline:none; background:none;}



	margin:0 1em;
	-webkit-align-self: flex-start;
	-ms-flex-align: start;
	align-self: flex-start; 

p{ line-height:200%; color:#ddd; margin:1em 0;}


                window.onload = function() {

var elInput = document.querySelector("#typeRange");
var filterImg = document.querySelector("#filterImg"); 
var Img = document.querySelector("#filterImg img");
var ImgW = parseInt(window.getComputedStyle(Img,null).getPropertyValue("width"));

var RB = document.querySelectorAll(".radioDiv [type=radio]");

var oFilter ={
	Blur:{       minim:0, maxim:100,  val:50,   div:10,    u:'px', filter:"blur"},
	Brightness:{ minim:0, maxim:100, val:15,    div:10,   u:'',   filter:"brightness"},
	Contrast:{   minim:0, maxim:100, val:25,    div:10,   u:'',   filter:"contrast"},
	Grayscale:{  minim:0, maxim:100, val:100,   div:100, u:'',   filter:"grayscale"},
	HueRotate:{  minim:0, maxim:360, val:230,   div:1,   u:'deg',filter:"hue-rotate"},
	Invert:{     minim:0, maxim:100, val:100,    div:100, u:'',   filter:"invert"},
	//Opacity:{    minim:0, maxim:100, val:100, div:100, u:'',   filter:"opacity"},
	Saturate:{   minim:0, maxim:100,  val:30,   div:10,   u:'',   filter:"saturate"},
	Sepia:{      minim:0, maxim:100, val:100,   div:100, u:'',   filter:"sepia"}


var oFilterKeys = Object.keys(oFilter);

var controlTypeRange = document.querySelectorAll("#control [type=range]");

// initial setting CSS FILTER
var radioChecked = document.querySelector("[type=radio]:checked");
var initialFilter = oFilter[radioChecked.value].filter;
var initialValue = oFilter[radioChecked.value].val;
var initialDiv = oFilter[radioChecked.value].div;
var initialU = oFilter[radioChecked.value].u; = initialFilter+"("+initialValue/initialDiv +initialU+")"; = initialFilter+"("+initialValue/initialDiv +initialU+")";

// IMAGE width 
    var w = this.value; = ((ImgW * w)/100)+"px";
}, false);

for(var i = 0; i < oFilterKeys.length; i++){
	var filter = oFilter[oFilterKeys[i]].filter;
	var radio = document.querySelector("#"+oFilterKeys[i]+" [type=radio]");
	var range = document.querySelector("#"+oFilterKeys[i]+" [type=range]");
	if(radio.checked == true){range.disabled = false}else{range.disabled = true};
	var display = document.querySelector("#"+oFilterKeys[i]+"span");
		var elId =;
		var range = document.querySelector("#"+elId+" [type=range]");
		var divisor = oFilter[elId].div;
		var rangeValue = (range.value)/divisor;
		var thisFilter = oFilter[elId].filter;
		var u = oFilter[elId].u; = thisFilter+"("+rangeValue+u+")"; = thisFilter+"("+rangeValue+u+")";
		for( var r= 0; r < controlTypeRange.length; r++ ){
			if(controlTypeRange[r].disabled == false){controlTypeRange[r].disabled = true;}
			range.disabled = false;
	// RANGE	
		var divisor = oFilter[].div;
		var rangeValue = this.value/divisor;
		var thisFilter = oFilter[].filter;
		var u = oFilter[].u;
		var display = document.querySelector("#"" span"); = thisFilter+"("+rangeValue+u+")"; = thisFilter+"("+rangeValue+u+")";
		display.innerHTML = this.value/divisor + u;