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

              
                <p>Mueva la rueda del rat&oacute;n</p>
<svg width="245" height="245" viewBox="0 0 245 245">
    <defs>
   <linearGradient id="grd" x1="100%" y1="0%" x2="100%" y2="100%"> 
        <stop offset="0%" stop-color="hsl(31,43%,70%)"/>
        <stop offset="100%" stop-color="hsl(31,90%,30%)"/>
   </linearGradient>
 </defs>
  <path class="coffee" fill="hsla(31,43%,60%,0)" d="M47.265 155.576c23.197 11.046 58.908 12.15 75.11 12.887s52.4-6.697 56.082-7.065c0 0-26.99 56.68-58.656 56.975-57.805.537-72.535-62.797-72.535-62.797z"/>
  <g stroke="url(#grd)">
    <path id ="cup" stroke-width = "2" d="M115.173 153.698c-7.624 0-16.477 1.23-5.41 1.476s25.576.738 17.46-1.476-33.692-4.428-34.43-.984 23.662 5.165 36.793 3.936 25.992.07 25.428-3.936c-.49-3.486-26.315-5.41-45.744-5.164-12.598.16-48.694 2.46-49.678 4.92s38.12 5.9 47.22 6.393 73.533-.492 77.22-5.902-32.708-10.82-72.057-11.31c-39.35-.493-68.37 5.41-70.582 7.377s14.71 75.01 72.303 75.01c29.11 0 47.218-22.134 55.088-34.923s16.23-29.02 25.33-30.987 8.362 4.918 8.608 8.36-2.46 32.956-14.264 32.464-11.56-7.13-11.56-7.13"/>
    <path id="plate" stroke-width = "3" d="M50 218.132s-6.885-.737-6.885 3.197 19.674 14.755 62.466 13.28 73.534-8.362 77.715-15.003"/>
    <g id="steam" stroke-width = "1">
    <path id="steam_right" d="M105.09 136.975s11.66-10.083 11.118-24.593-23.906-15.248-23.906-19.43 21.64-17.214 27.79-26.56 1.563-29.512 1.52-37.38 1.685-8.608 1.685-8.608"/>
    <path id="steam_left" d="M100.09 125.768s11.66-10.083 11.118-24.593c-.543-14.51-23.906-15.248-23.906-19.428s21.64-17.215 27.79-26.56 1.563-29.513 1.52-37.382 1.685-8.607 1.685-8.607"/>
    </g>
  </g>
</svg>
          
              
            
!

CSS

              
                svg {
  border: 1px solid #d9d9d9;
  display: block;
  margin: 0 auto;
  fill: none;
}

.coffee {
  stroke-width: 0;
}

p {
  text-align: center;
  color:hsl(31,43%,40%);
  font-family: Verdana, Geneva, sans-serif;
}
              
            
!

JS

              
                var svg = document.querySelector("svg");
var coffee = document.querySelector("svg .coffee");
var l = 800;
var dasharray = l;
var dashoffset = l;
svg.style.strokeDasharray = dasharray;
svg.style.strokeDashoffset = dashoffset;

document.addEventListener("wheel",

  function(e) {

    e.preventDefault();
    if (dashoffset > 0 && e.deltaY > 0 || 
        dashoffset < l && e.deltaY < 0) {
        dashoffset -= e.deltaY;
    }
   if(dashoffset < 0)dashoffset = 0;
   if(dashoffset > l)dashoffset = l;
    
    svg.style.strokeDashoffset = dashoffset;
    var alpha = map(dashoffset, 0, l, .5, 0);
    coffee.style.fill = "hsla(31,43%,60%,"+alpha+")"
  }, false);

function map(n, a, b, _a, _b) {
  var d = b - a;
  var _d = _b - _a;
  var u = _d / d;
  return _a + n * u;
}

              
            
!
999px

Console