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.


                <svg class="parent" viewBox="0 0 500 600" class="parent">
  <rect x="0" y="0" width="500" height="600" fill="white" />
  <text transform="translate(250 50)" font-size="40" fill="#000" text-anchor="middle">Parent SVG</text>
  <svg class="nested" viewBox="0 0 500 500">
    <circle cx="50%" cy="50%" r="50%" fill="#88ce02" />
    <text transform="translate(250 260)" font-size="60" fill="#fff" text-anchor="middle">Nested</text>
  <rect x="0" y="500" width="500" height="100" fill="#000" />
  <g class="dragger">
    <rect x="0" y="500" width="100" height="100" fill="#444" />
    <text transform="translate(50 540)" font-size="16" fill="#fff" text-anchor="middle">Drag to scale</text>
    <text class="scaleText" transform="translate(50 570)" font-size="20" fill="#fff" text-anchor="middle">1.00</text>


                * {
  box-sizing: border-box;

body {
  padding: 0;
  margin: 0;
  overflow: hidden;
  background-color: #1B1B1B;

.parent {
  font-family: "Roboto", sans-serif;
  position: absolute;
  left: 50%;
  overflow: visible;


let data = document.querySelector(".nested").getBBox();
let text = document.querySelector(".scaleText");

// change the origins to make the nested SVG grow from that point
let originX = 250; // change to desired x scale start point
let originY = 250; // change to desired y scale start point

gsap.set(".parent", { xPercent: -50, yPercent: -50 });
gsap.set(".nested", {
  attr: { width: data.width, height: data.height, x: data.x, y: data.y }
gsap.set(".dragger", { x: 400 });

function scaleNested() {
  let scale = this.x / 400;
  text.innerHTML = scale.toFixed(2);
  let newSize = data.width * scale;
  let newPositionX = (1 - scale) * originX;
  let newPositionY = (1 - scale) * originY;
  gsap.set(".nested", {
    attr: { width: newSize, height: newSize, x: newPositionX, y: newPositionY }

Draggable.create(".dragger", {
  type: "x",
  bounds: {
    minX: 0,
    maxX: 400
  onDrag: scaleNested