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

              
                <figure>
  <div class="outer">
    <div class="inner">
    </div>
  </div>
  <figcaption>
    <span class="outer-radius">50</span>px 
    - 
    <span class="padding">25</span>px 
    = 
    <span class="inner-radius">25</span>px
  </figcaption>
</figure>

<form>
  <label>
    Outer Border Radius
    <input type="range" min="0" max="100" value="50" name="radius"/>
  </label>
  
  <label>
    Gap
    <input type="range" min="0" max="50" value="25" name="padding"/>
  </label>
</form>
              
            
!

CSS

              
                :root {
  --demo-width: min(20em, 80vw);
  --hue: 220;
  --stroke-hue: 275;
}
figure {
  --padding: 25px;
  --radius: 50px;
  
  --demo-width: min(20em, 80vw);
}

* {
  margin: 0;
}

html, body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-family: Source Sans Pro, Source Sans, system-ui, sans-serif;
}

body {
  padding-block: 1em;
  gap: 2em;
  background-color: hsl(var(--stroke-hue), 20%, 90%);
}

figure {
  background: hsl(var(--stroke-hue), 60%, 98.5%);
  box-shadow:   0px 0.8px 2.2px hsla(var(--hue), 100%, 10%, 0.02),
  0px 1.9px 5.3px hsla(var(--hue), 100%, 10%, 0.028),
  0px 3.6px 10px hsla(var(--hue), 100%, 10%, 0.035),
  0px 6.5px 17.9px hsla(var(--hue), 100%, 10%, 0.042),
  0px 12.1px 33.4px hsla(var(--hue), 100%, 10%, 0.05),
  0px 29px 80px hsla(var(--hue), 100%, 10%, 0.07);
    
  width: var(--demo-width);
  height: var(--demo-width);
  padding-top: 1em;
  padding-left: 1em;
  display: grid;
  place-items: stretch;
  position: relative;
}

figcaption {
  background: hsl(var(--hue), 60%, 95%);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5em;
  text-align: center;
  font-variant-numeric: tabular;
  font-size: 1.5em;
}

.outer { 
  background: hsl(275, 95%, 60%);
  display: grid;
  place-items: stretch;
  padding-top: var(--padding);
  padding-left: var(--padding);
  border-top-left-radius: var(--radius);
}

.inner {
  background: hsl(220, 30%, 85%);
  border-top-left-radius: calc(var(--radius) - var(--padding));
}

form {
  width: var(--demo-width);
  display: grid;
  gap: 1em;
}

label {
  font-weight: bold;
  font-size: 1.25rem;
}

input {
  accent-color: hsl(275, 95%, 60%);
  display: block;
  width: 100%;
}
              
            
!

JS

              
                const figureEl = document.querySelector('figure');
const inputs = document.querySelectorAll('input');

const radiusInputEl = document.querySelector('[name="radius"]');
const paddingInputEl = document.querySelector('[name="padding"]');

const outerRadiusEl = document.querySelector('.outer-radius');
const innerRadiusEl = document.querySelector('.inner-radius');
const paddingEl = document.querySelector('.padding');

function updateFigure({target}) {
  figureEl.style.setProperty(`--${target.name}`, `${target.value}px`);
    
  outerRadiusEl.textContent = radiusInputEl.value;
  paddingEl.textContent = paddingInputEl.value;
  innerRadiusEl.textContent = radiusInputEl.value - paddingInputEl.value;
}

document.addEventListener('input', updateFigure);
document.addEventListener('change', updateFigure)
              
            
!
999px

Console