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

              
                <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <style type="text/css">
        <![CDATA[
            .side{
                fill: #7BA2FF;
            }

            .slice{
                fill:#466DB7;
            }

            .mask{
                fill:white;
                stroke:black;
                stroke-width:200px;
            }
        ]]>
    </style>

    <defs>
        <mask id="mask-left-right">
            <rect class="mask" width="300px" height="100%" x="-100px"/>
        </mask>

        <mask id="mask-top-bottom">
            <rect class="mask" width="100%" height="300px" y="-100px"/>
        </mask>

        <mask id="mask-center">
            <rect class="mask" width="100%" height="100%"/>
        </mask>

        <symbol id="side" viewBox="0 0 200 100"  preserveAspectRatio="none">
            <polygon class="side" points="135.5,0 100,35.5 64.5,0 0,0 0,100 200,100 200,0 "/>
        </symbol>

        <symbol  id="corner" width="100px" height="100px" viewBox="0 0 100 100">
            <rect class="slice" x="-35" y="50" transform="rotate(-45 50 50)" class="st0" width="170" height="100"/>
            <rect class="slice" x="30" y="30" class="st0" width="40" height="40"/>
        </symbol>

        <symbol  id="leftRight" viewBox="0 0 100 200"  preserveAspectRatio="none">
            <use xlink:href="#side" width="200px" height="100px" transform="rotate(-90 100 100)"/>
        </symbol>

        <symbol  id="topBottom" viewBox="0 0 200 100"  preserveAspectRatio="none">
            <use xlink:href="#leftRight" transform="rotate(90)" width="100" height="200" x="0" y="-200"/>
        </symbol> 
    </defs>
    
    <!-- top-left corner: -->
    <use xlink:href="#corner" width="100px" height="100px"/>

    <!-- bottom-left corner: -->
    <use xlink:href="#corner" transform="scale(1, -1)" style="overflow:visible;" width="100px" height="100px" x="0" y="-100%"/>

    <!-- top-right corner: -->
    <use xlink:href="#corner" transform="scale(-1, 1)" width="100px" height="100px" x="-100%" y="0" />

    <!-- bottom-right corner: -->
    <use xlink:href="#corner" transform="scale(-1, -1)" width="100px" height="100px" x="-100%" y="-100%"/>

    <!-- top edge: -->
    <use class="" xlink:href="#side" width="100%" height="100" x="0" y="0"  mask="url(#mask-top-bottom)"/>
    <!-- bottom edge: -->
    <use class="" xlink:href="#side" transform="scale(1,-1)" width="100%" height="100" x="0" y="-100%"  mask="url(#mask-top-bottom)"/>
    <!-- right edge: -->
     <use class="" xlink:href="#leftRight" transform="scale(-1,1)" width="100" height="100%" x="-100%" y="0" mask="url(#mask-left-right)"/> 
     <!-- left edge: -->
    <use class="" xlink:href="#leftRight" width="100" height="100%" x="0" y="0" mask="url(#mask-left-right)"/>

    <!-- center: -->
    <rect class="slice" width="100%" height="100%" mask="url(#mask-center)"/>   
</svg>
       <p>Constructing an SVG with an "almost" perfect 9-slice scaling grid: the sides and the center of this image are flexible, the corners are fixed. Resize your browser window to see the effect in action. Read accompanying <a href="http://w3.eleqtriq.com/?p=1177">article here</a>.</p>  
              
            
!

CSS

              
                @import "compass/css3";

html{
            height: 100%;
            background: white;
            overflow: auto;
        }
        
        body{
            margin: 0;
            height: 100%;
            overflow: auto;
            background:  #FFCC66;
        } 

        body>svg{
            display: block;
            width:70%;
            height: 70%;
            position: relative;
            margin: 30px auto;
            min-width: 400px;
            min-height: 400px;
        }

        p{
            color: black;
            text-align: center;
            margin: 0 10%;
            font: 1em/1 sans-serif;
            color: black;
        }
              
            
!

JS

              
                
              
            
!
999px

Console