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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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 id="generated-text">
  <h1 class="text"><span class="colorfill" data-content="colorfill" aria-hidden="true"></span>colorfill</h1>
</div>
<p class="subtitle">A desktop app for generating text fill animations</p>
<div class="links">
  <a href="https://www.npmjs.com/package/colorfilljs" target="_blank">npm</a>
  <a href="https://github.com/christianbmartinez/colorfilljs" target="_blank">github</a>
</div>
<label for="text">Text:</label>
<input name="text" value="colorfill" type="text" placeholder="colorfill" id="word">
<br><br>

<label for="text-tag">Tag:</label>
<select name="text-tag" id="tag">
  <option value="h1">h1</option>
  <option value="h2">h2</option>
  <option value="h3">h3</option>
  <option value="h4">h4</option>
  <option value="h5">h5</option>
  <option value="h6">h6</option>
  <option value="p">p</option>
  <option value="a">a</option>
</select>
<br><br>

<label for="color">Color:</label>
<input name="color" type="color" placeholder="#ca3434" value="#ff61c8" id="color">
<br><br>

<label for="fill-color">Fill:</label>
<input name="fill-color" type="color" placeholder="#000000" value="#3e309c" id="fill-color">
<br><br>

<label for="cursor">Cursor:</label>
<select name="cursor" id="cursor">
  <option value="default">default</option>
  <option value="auto">auto</option>
  <option value="none">none</option>
  <option value="context-menu">context-menu</option>
  <option value="help">help</option>
  <option value="pointer">pointer</option>
  <option value="progress">progress</option>
  <option value="wait">wait</option>
  <option value="cell">cell</option>
  <option value="crosshair">crosshair</option>
  <option value="text">text</option>
  <option value="vertical-text">vertical-text</option>
  <option value="alias">alias</option>
  <option value="copy">copy</option>
  <option value="move">move</option>
  <option value="no-drop">no-drop</option>
  <option value="not-allowed">not-allowed</option>
  <option value="grab">grab</option>
  <option value="grabbing">grabbing</option>
  <option value="all-scroll">all-scroll</option>
  <option value="col-resize">col-resize</option>
  <option value="row-resize">row-resize</option>
  <option value="n-resize">n-resize</option>
  <option value="e-resize">e-resize</option>
  <option value="s-resize">s-resize</option>
  <option value="w-resize">w-resize</option>
  <option value="ne-resize">ne-resize</option>
  <option value="nw-resize">nw-resize</option>
  <option value="se-resize">se-resize</option>
  <option value="sw-resize">sw-resize</option>
  <option value="ew-resize">ew-resize</option>
  <option value="ns-resize">ns-resize</option>
  <option value="nesw-resize">nesw-resize</option>
  <option value="nwse-resize">nwse-resize</option>
  <option value="zoom-in">zoom-in</option>
  <option value="zoom-out">zoom-out</option>
</select>
<br><br>
<label for="duration">Duration:</label>
<input name="duration" type="range" min="0.25" max="5" value="0.75" step="0.1" id="duration">
<label id="duration-output">0.75s</label>
<br><br>

<label for="position-one">Position 1:</label>
<input name="position-one" type="range" min="-100" max="100" value="-100" step="1" id="position-one">
<label id="position-one-output">-100%</label>
<p id="reset-one">Reset</p>
<br><br>

<label for="position-two">Position 2:</label>
<input name="position-two" type="range" min="-100" max="100" value="100" step="1" id="position-two">
<label id="position-two-output">100%</label>
<p id="reset-two">Reset</p>
<br><br>

<label for="position-three">Position 3:</label>
<input name="position-three" type="range" min="-100" max="100" value="0" step="1" id="position-three">
<label id="position-three-output">0%</label>
<p id="reset-three">Reset</p>
<br><br>

<label for="axis">Axis:</label>
<select name="axis" id="axis">
  <option value="X">X</option>
  <option value="Y">Y</option>
</select>
<br><br>

<label for="timing">Timing:</label>
<select name="timing" id="timing">
  <option value="ease">ease</option>
  <option value="ease-in">ease-in</option>
  <option value="ease-out">ease-out</option>
  <option value="ease-in-out">ease-in-out</option>
  <option value="linear">linear</option>
</select>
<br><br>

<p id="copy"></p>

<div class="output-container">
  <div id="css-output"></div>
  <div id="html-output"></div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;700;900&display=swap");

:root {
  --position-one: translateX(-100%);
  --position-two: translateX(100%);
  --position-three: translateX(0);
  --duration: 0.75s;
  --timing: ease-in-out;
  --color: #d9269a;
  --fill-color: #161a3c;
  --bg-color: #f9f9f9;
  --cursor: default;
  --thin: 100;
  --regular: 300;
  --semi-bold: 700;
  --bold: 900;
}

* {
  font-family: "Roboto", sans-serif;
  letter-spacing: 2px;
}

body {
  text-align: center;
  background-color: var(--bg-color);
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px grey;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fill-color);
}

/* CHROME */
input[type="range"] {
  overflow: hidden;
  width: 80px;
  -webkit-appearance: none;
  background-color: var(--fill-color);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  -webkit-appearance: none;
  background-color: var(--fill-color);
  margin-top: -1px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 10px;
  -webkit-appearance: none;
  height: 10px;
  cursor: ew-resize;
  background-color: var(--color);
  box-shadow: -80px 0 0 80px var(--color);
}

/** FF*/
input[type="range"]::-moz-range-progress {
  background-color: var(--fill-color);
}

input[type="range"]::-moz-range-track {
  background-color: var(--color);
}

/* IE*/
input[type="range"]::-ms-fill-lower {
  background-color: var(--fill-color);
}

input[type="range"]::-ms-fill-upper {
  background-color: var(--color);
}

h1 {
  font-size: 70px;
  font-weight: var(--bold);
}

h2 {
  font-size: 65px;
  font-weight: var(--bold);
}

h3 {
  font-size: 60px;
  font-weight: var(--bold);
}

h4 {
  font-size: 55px;
  font-weight: var(--semi-bold);
}

h5 {
  font-size: 50px;
  font-weight: var(--semi-bold);
}

h6 {
  font-size: 45px;
  font-weight: var(--semi-bold);
}

p {
  font-size: 32px;
  font-weight: var(--regular);
}

p.subtitle {
  font-size: 20px;
  font-weight: var(--regular);
  margin-bottom: 80px;
}

p#copy {
  cursor: pointer;
  font-weight: var(--bold);
  color: var(--color);
  display: none;
}

p#copy:hover {
  color: var(--fill-color);
}

.links {
  display: block;
  margin: -35px 0 50px  0;
}

.links a {
  text-decoration: none;
  color: var(--color);
  padding: 10px;
  font-size: 15px;
}

.links a:hover {
  text-decoration: line-through;
  color: var(--fill-color);
}

.fade-in {
  animation: fadeIn var(--duration);
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 100%;
  }
}

#reset-one,
#reset-two,
#reset-three {
  font-size: 12px;
  letter-spacing: none;
  font-family: Arial, Helvetica, sans-serif;
  color: #888;
  display: none;
  margin-left: 10px;
  cursor: pointer;
}

a {
  font-size: 28px;
  font-weight: var(--regular);
}

input {
  font-size: 16px;
  padding: 5px;
  outline: none;
  border: none;
  border-radius: 4px;
}

.text {
  color: var(--color);
  cursor: var(--cursor);
  width: 100%;
}

span.colorfill {
  position: absolute;
  overflow: hidden;
  transform: var(--position-one);
  transition: transform var(--duration) var(--timing);
}

h1:hover span.colorfill,
h2:hover span.colorfill,
h3:hover span.colorfill,
h4:hover span.colorfill,
h5:hover span.colorfill,
h6:hover span.colorfill,
a:hover span.colorfill,
p:hover span.colorfill {
  transform: var(--position-three);
}

span.colorfill::before {
  display: inline-block;
  color: var(--fill-color);
  content: attr(data-content);
  transform: var(--position-two);
  transition: transform var(--duration) var(--timing);
}

h1:hover span.colorfill::before,
h2:hover span.colorfill::before,
h3:hover span.colorfill::before,
h4:hover span.colorfill::before,
h5:hover span.colorfill::before,
h6:hover span.colorfill::before,
a:hover span.colorfill::before,
p:hover span.colorfill::before {
  transform: var(--position-three);
}

.output-container {
  text-align: left;
  background-color: var(--fill-color);
  color: var(--color);
  height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  border-radius: 10px;
  display: none;
}

.output-container::-webkit-scrollbar-thumb:hover {
  background: var(--color);
}

              
            
!

JS

              
                /*

Author: Christian B. Martinez

Website: www.christianbmartinez.com

Date: 12/29/20

Purpose: Create an app that visualizes and creates css hover animations and outputs code to user.

Features: Copy to clipboard, reset independent values, color picker, custom scrollbar and range sliders, css vars. Some support for other browsers besides chrome, not optimized for mobile.

Note: Currently seeking a front end/software developer position. Hint hint! 

*/

var generatedText = document.getElementById("generated-text");
var wordInput = document.getElementById("word");
var word = wordInput.value;
var tagInput = document.getElementById("tag");
var tag = tagInput.value;
var colorInput = document.getElementById("color");
var color = colorInput.value;
var fillColorInput = document.getElementById("fill-color");
var fillColor = fillColorInput.value;
var cursorInput = document.getElementById("cursor");
var cursor = cursorInput.value;
var durationInput = document.getElementById("duration");
var duration = durationInput.value;
var durationOutput = document.getElementById("duration-output");
var timingInput = document.getElementById("timing");
var timing = timingInput.value;
var htmlOutput = document.getElementById("html-output");
var cssOutput = document.getElementById("css-output");
var outputContainer = document.querySelector(".output-container");
var positionOne = document.getElementById("position-one");
var getPositionOne = positionOne.value;
var positionOneOutput = document.getElementById("position-one-output");
var positionTwo = document.getElementById("position-two");
var getPositionTwo = positionTwo.value;
var positionTwoOutput = document.getElementById("position-two-output");
var positionThree = document.getElementById("position-three");
var axis = document.getElementById("axis");
var getAxis = axis.value;
var getPositionThree = positionThree.value;
var positionThreeOutput = document.getElementById("position-three-output");
var resetOne = document.getElementById("reset-one");
var resetTwo = document.getElementById("reset-two");
var resetThree = document.getElementById("reset-three");
var copy = document.getElementById("copy");

function copyToClipboard() {
  var range = document.createRange();
  range.selectNode(outputContainer);
  window.getSelection().removeAllRanges();
  window.getSelection().addRange(range); 
  document.execCommand("copy");
  window.getSelection().removeAllRanges(); 
}

axis.onchange = () => {
  getAxis = axis.value;
  if (getAxis === "X") {
    document.documentElement.style.setProperty(
      "--position-one",
      "translateX(" + getPositionOne + "%)"
    );
  } else {
    document.documentElement.style.setProperty(
      "--position-one",
      "translateY(" + getPositionOne + "%)"
    );
  }
  render();
};

wordInput.onchange = () => {
  word = wordInput.value;
  generatedText.innerHTML =
    "<" +
    tag +
    ' class="text"' +
    ">" +
    '<span class="colorfill" data-content="' +
    word +
    '" aria-hidden="true"></span>' +
    word +
    "<" +
    "/" +
    tag +
    ">";
  render();
};

tagInput.onchange = () => {
  tag = tagInput.value;
  generatedText.innerHTML =
    "<" +
    tag +
    ' class="text"' +
    ">" +
    '<span class="colorfill" data-content="' +
    word +
    '" aria-hidden="true"></span>' +
    word +
    "<" +
    "/" +
    tag +
    ">";
  render();
};

colorInput.onchange = () =>  {
  color = colorInput.value;
  document.documentElement.style.setProperty("--color", color);
  render();
};

fillColorInput.onchange = () =>  {
  fillColor = fillColorInput.value;
  document.documentElement.style.setProperty("--fill-color", fillColor);
  render();
};

cursorInput.onchange = () => {
  cursor = cursorInput.value;
  document.documentElement.style.setProperty("--cursor", cursor);
  render();
};

durationInput.onmouseup = () => {
  duration = durationInput.value;
  document.documentElement.style.setProperty("--duration", duration + "s");
  render();
};

durationInput.onmousemove = () => {
  durationOutput.innerHTML = durationInput.value + "s";
};

positionOne.onclick = () =>  {
  resetOne.style.display = "inline-block";
  resetOne.onclick = function () {
    positionOne.value = -100;
    positionOneOutput.innerHTML = positionOne.value + "%";
    getPositionOne = positionOne.value;
    resetOne.style.display = "none";
    if (getAxis === "X") {
      document.documentElement.style.setProperty(
        "--position-one",
        "translateX(" + getPositionOne + "%)"
      );
    } else {
      document.documentElement.style.setProperty(
        "--position-one",
        "translateY(" + getPositionOne + "%)"
      );
    }
    render();
  };
  getPositionOne = positionOne.value;
  if (getAxis === "X") {
    document.documentElement.style.setProperty(
      "--position-one",
      "translateX(" + getPositionOne + "%)"
    );
  } else {
    document.documentElement.style.setProperty(
      "--position-one",
      "translateY(" + getPositionOne + "%)"
    );
  }
  positionOneOutput.innerHTML = positionOne.value + "%";
  render();
};

positionTwo.onclick = () => {
  resetTwo.style.display = "inline-block";
  resetTwo.onclick = function () {
    positionTwo.value = 100;
    positionTwoOutput.innerHTML = positionTwo.value + "%";
    getPositionTwo = positionTwo.value;
    resetTwo.style.display = "none";
    if (getAxis === "X") {
      document.documentElement.style.setProperty(
        "--position-two",
        "translateX(" + getPositionTwo + "%)"
      );
    } else {
      document.documentElement.style.setProperty(
        "--position-two",
        "translateY(" + getPositionTwo + "%)"
      );
    }
    render();
  };
  getPositionTwo = positionTwo.value;
  if (getAxis === "X") {
    document.documentElement.style.setProperty(
      "--position-two",
      "translateX(" + getPositionTwo + "%)"
    );
  } else {
    document.documentElement.style.setProperty(
      "--position-two",
      "translateY(" + getPositionTwo + "%)"
    );
  }
  positionTwoOutput.innerHTML = positionTwo.value + "%";
  render();
};

positionThree.onclick = () =>  {
  resetThree.style.display = "inline-block";
  resetThree.onclick = function () {
    positionThree.value = 0;
    positionThreeOutput.innerHTML = positionThree.value + "%";
    getPositionThree = positionThree.value;
    resetThree.style.display = "none";
    if (getAxis === "X") {
      document.documentElement.style.setProperty(
        "--position-three",
        "translateX(" + getPositionThree + "%)"
      );
    } else {
      document.documentElement.style.setProperty(
        "--position-three",
        "translateY(" + getPositionThree + "%)"
      );
    }
    render();
  };
  getPositionThree = positionThree.value;
  if (getAxis === "X") {
    document.documentElement.style.setProperty(
      "--position-three",
      "translateX(" + getPositionThree + "%)"
    );
  } else {
    document.documentElement.style.setProperty(
      "--position-three",
      "translateY(" + getPositionThree + "%)"
    );
  }
  positionThreeOutput.innerHTML = positionThree.value + "%";
  render();
};

timingInput.onchange = () => {
  timing = timingInput.value;
  document.documentElement.style.setProperty("--timing", timing);
  render();
};

function render() {
  copy.innerHTML = "Copy";
  outputContainer.classList.add("fade-in");
  outputContainer.style.display = "block";
  copy.style.display = "block";
  copy.onclick = function () {
    copyToClipboard();
    copy.innerHTML = "Copied!";
  };
  cssOutput.innerHTML =
    "/* Generated by colorfill */<br><br>" +
    `-- CSS -- <br><br>
      .text { <br>
        color: ` +
    color +
    `;<br>
        cursor: ` +
    cursor +
    `; <br>
        width: 100%;<br>
      }<br><br>
      
      span.colorfill {<br>
        position: absolute;<br>
        overflow: hidden;<br>
        transform: translate` +
    getAxis +
    `(` +
    getPositionOne +
    `%);<br>
        transition: transform  ` +
    duration +
    "s " +
    timing +
    `;<br>
      }<br><br>
      ` +
    tag +
    `:hover span.colorfill {<br>
        transform: translate` +
    getAxis +
    `(` +
    getPositionThree +
    `%);<br>
      }<br><br>
      
      span.colorfill::before { <br>
        display: inline-block;<br>
        color: ` +
    fillColor +
    `;<br>
        content: attr(data-content);<br>
        transform: translate` +
    getAxis +
    `(` +
    getPositionTwo +
    `%);<br>
        transition: transform  ` +
    duration +
    "s " +
    timing +
    `;<br>
      }<br><br>
      
      ` +
    tag +
    `:hover span.colorfill::before {<br>
        transform: translate` +
    getAxis +
    `(` +
    getPositionThree +
    `%);<br>
      }<br><br>
      
      -- HTML -- <br><br>`;

  htmlOutput.textContent =
    "<" +
    tag +
    ' class="text"' +
    ">" +
    '<span class="colorfill" data-content="' +
    word +
    '" aria-hidden="true"></span>' +
    word +
    "<" +
    "/" +
    tag +
    ">";
}

              
            
!
999px

Console