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

              
                <h1>MonoChromey</h1>
<p>Hold down on the image to temporarily cancel the effect</p>
<p class="image-holder">
  <img src="https://source.unsplash.com/1200x800/?nature,water" alt="Random water image from unsplash">
</p>
<form>
  <input type="range" id="hue-input" min="0" max="360" value="60"><br>
  <input type="text" id="style-output" readonly>
</form>

<p>Home: <a href="https://atornblad.se/">atornblad.se</a>, Twitter: <a href="https://twitter.com/atornblad">@atornblad</a>, Dev: <a href="https://dev.to/atornblad">@atornblad</a></p>
<p>Blog: <a href="https://atornblad.se/monochromey-css">atornblad.se/monochromey-css</a></p>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

html {
  align-items: center;
}

body {
  background: #333;
  align-items: stretch;
  min-height: 100vh;
  font-family: sans-serif;
  color: #eee;
  text-align: center;
}

h1, p {
  margin-bottom: 0;
}

a:link, a:visited {
  color: #19f;
  text-decoration: underline;
}

a:link::first-letter {
  text-decoration: none;
}

body > * {
  max-width: 90vw;
}

p.image-holder > img {
  border-radius: 10px;
  box-shadow: 0 2px 3px 1px black;
  transition: filter 0.2s ease-in-out;
}

input[type=text] {
  width: 100%;
  margin-top: 20px;
  font-family: monospace;
  font-size: 20px;
  border-radius: 5px;
  padding: 10px;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-ms-track {
  width: 100%;
  cursor: pointer;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  border-color: transparent;
  color: transparent;
}

input[type=range]::-webkit-slider-runnable-track{
  width: 100%;
  height: 15px;
  cursor: pointer;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  background: linear-gradient(to right, hsl(0deg 50% 50%), hsl(60deg 50% 50%), hsl(120deg 100% 50%), hsl(180deg 50% 50%), hsl(240deg 50% 50%), hsl(300deg 50% 50%), hsl(360deg 50% 50%));
  border-radius: 3px;
  border: 1px solid #010101;
}

input[type=range]:focus::-webkit-slider-runnable-track {
  background: linear-gradient(to right, hsl(0deg 100% 50%), hsl(60deg 100% 50%), hsl(120deg 100% 50%), hsl(180deg 100% 50%), hsl(240deg 100% 50%), hsl(300deg 100% 50%), hsl(360deg 100% 50%));
}

input[type=range]::-moz-range-track{
  width: 100%;
  height: 15px;
  cursor: pointer;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  background: linear-gradient(to right, hsl(0deg 50% 50%), hsl(60deg 50% 50%), hsl(120deg 100% 50%), hsl(180deg 50% 50%), hsl(240deg 50% 50%), hsl(300deg 50% 50%), hsl(360deg 50% 50%));
  border-radius: 3px;
  border: 1px solid #010101;
}

input[type=range]:focus::-moz-range-track {
  background: linear-gradient(to right, hsl(0deg 100% 50%), hsl(60deg 100% 50%), hsl(120deg 100% 50%), hsl(180deg 100% 50%), hsl(240deg 100% 50%), hsl(300deg 100% 50%), hsl(360deg 100% 50%));
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  border: 1px solid #000000;
  height: 36px;
  width: 16px;
  border-radius: 3px;
  background: #ffffff;
  cursor: pointer;
  margin-top: -12px;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; /* Add cool effects to your sliders! */
}

input[type=range]::-moz-range-thumb {
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  border: 1px solid #000000;
  height: 36px;
  width: 16px;
  border-radius: 3px;
  background: #ffffff;
  cursor: pointer;
}

@media (max-width: 1279px) {
  p.image-holder > img {
    width: 800px;
    height: auto;
  }
  
  input[type=text] {
    font-size: 16px;
    padding: 8px;
  }
}

@media (max-width: 879px) {
  p.image-holder > img {
    width: 500px;
    height: auto;
  }
  
  input[type=text] {
    font-size: 14px;
    padding: 7px;
  }
}

@media (max-width: 579px) {
  p.image-holder > img {
    width: 300px;
    height: auto;
  }
  
  input[type=text] {
    font-size: 12px;
    padding: 6px;
  }
}
              
            
!

JS

              
                const img = document.querySelector('p.image-holder > img');
const range = document.getElementById('hue-input');
const output = document.getElementById('style-output');

const setFilter = (filter) => {
  output.value = `filter: ${filter}`;
  img.style.filter = filter;
}

const handleHueInput = (hue) => {
  const filter = `sepia() hue-rotate(${hue - 60}deg)`;
  setFilter(filter);
};

const handleRange = (e) => {
  e && e.preventDefault();
  handleHueInput(parseInt(range.value, 10));
};

const handleMouseDown = (e) => {
  e && e.preventDefault();
  setFilter('none');
};

const handleMouseUp = handleRange;

handleRange();
range.addEventListener('input', handleRange );

img.addEventListener('mousedown', handleMouseDown);
img.addEventListener('mouseup', handleMouseUp);
img.addEventListener('touchstart', handleMouseDown);
img.addEventListener('touchend', handleMouseUp);

              
            
!
999px

Console