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>Hit the circle </h1>
<svg height="150" width="100%">
  <circle id="catch-me" r="50" cy="75">
    <animate attributeName="cx"
             values="0%;100%;30%;65%;5%;95%;0%"
             dur="5s"
             repeatDur="indefinite"
             calcMode="paced" />
             
  </circle>
</svg>
<ul id="log"></ul>
<p>Although the circle is animated using SMIL, the SVG DOM still provides a way to figure out exactly where it is (i.e., the current value of the <code>cx</code> attribute) at the time of processing the event.  Every time the circle receives a mousedown event, it will be logged above.
</p>
<p>P.S.: I'm using a mousedown event, because very few click events were getting through—the circle was moving out from under the mouse before the mouseup (and therefore click) was getting processed. If the circle is still moving too fast, increase the <code>dur</code> attribute, or reduce the width of the frame.</p>
  
              
            
!

CSS

              
                circle#catch-me {
  stroke:#222;
  stroke-width:8;
  fill:#888;
}
circle#catch-me:hover {
  stroke:#4f4;
}
svg {
  background: linear-gradient(to bottom, lightyellow 10%, tomato 40%, darkred, tomato 60%, lightyellow 90%);
}
h1 {
  position: absolute;
  width: 100%;
  text-align: center;
  text-shadow: 0 0 0.3em #eee, 0 0 0.1em #eee;
  pointer-events: none;
}
body:hover h1 {
  opacity: 0.2;
}
ul#log:not(:empty) {
  padding-bottom: 1em;
  border-bottom: gray 2px solid;
}
              
            
!

JS

              
                var log = document.getElementById("log");
document.getElementById("catch-me")
        .addEventListener("mousedown", logAnimations);

function logAnimations(e){
  var c = e.target,
      l = document.createElement("li");
  l.textContent = ["Clicked at ",
                   c.cx.animVal.valueAsString,
                   " (",
                   c.cx.animVal.value,
                   "px)"
                   ].join("");
  log.insertBefore(l, null);
}
              
            
!
999px

Console