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

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

              
                <h3>Illustrates zoom in / zoom out like quality of viewBox</h3>

<p>In all cases the width and height of the svg element are unchanged, the viewBox is altered in each example governing what can be seen within the viewport.</p>
<p>reference: https://developer.mozilla.org/en/docs/Web/SVG/Attribute/preserveAspectRatio</p>

<svg width="200" height="200" viewBox="0 0 800 800" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="200" height="200" viewBox="0 0 400 400" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="200" height="200" viewBox="0 0 200 200" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="200" height="200" viewBox="0 0 100 100" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="200" height="200" viewBox="0 0 50 50" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
</br>
<h3>preserveAspectRatio Examples</h3>
<p>Attribute preserveAspectRatio indicates whether or not to force uniform scaling. </p>

<h3>Meet or Slice</h3>
<p> Meet: the entire viewBox is visible within the viewport, viewBox is scaled up as much as possible.</p>
<svg width="400" height="200" viewBox="0 0 75 75" preserveAspectRatio="xMaxYMid slice" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<p> Slice: the entire viewport is covered by viewBox, viewBox is scaled down as much as possible.</p>
<svg width="400" height="200" viewBox="0 0 75 75" preserveAspectRatio="xMaxYMid meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<br/>
<h3>Change X values - xMin, xMid, xMax</h3>
<svg width="400" height="200" viewBox="0 0 50 50" preserveAspectRatio="xMinYMax meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="400" height="200" viewBox="0 0 50 50" preserveAspectRatio="xMidYMax meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="400" height="200" viewBox="0 0 50 50" preserveAspectRatio="xMaxYMax meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<br/>
<h3> No change here for Y values given width and height</h3>
<svg width="400" height="200" viewBox="0 0 50 50" preserveAspectRatio="xMinYMin meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="400" height="200" viewBox="0 0 50 50" preserveAspectRatio="xMinYMid meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="400" height="200" viewBox="0 0 50 50" preserveAspectRatio="xMinYMax meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<h3> Change height of SVG to see changes for Y values - Ymin, Ymid, Ymax </h3>
<svg width="200" height="400" viewBox="0 0 50 50" preserveAspectRatio="xMinYMin meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="200" height="400" viewBox="0 0 50 50" preserveAspectRatio="xMinYMid meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
<svg width="200" height="400" viewBox="0 0 50 50" preserveAspectRatio="xMinYMax meet" style="border: 1px solid #cccccc;">
    <circle cx="50" cy="50" r="25" style="stroke: #000000; fill:#00ff00;"/>
</svg>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console