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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <h1>Test Scaling Of SVG Images In Fluid Layouts</h1>

<p><em>Resize your browser so that the images scale down.</em></p>

<p>Browsers IE9+ do not respect ratios of SVG images inside <code>img</code> tags in fluid layouts. All other browsers scale SVG images as expected with the default output of an Illustrator file. This is a series of tests of SVG images using different attributes on the SVG tag.</p>

<p>One of the resolutions is to force IE to expand <code>img</code> tags containing SVG images to 100% of the container. This is not always desired, but does at least get IE to behave itself with ratio'd scaling.</p>

<p><strong>Uncomment the media query</strong> in the CSS to fix the issue in IE.</p>

<p>Other solutions are available in <a href="https://gist.github.com/larrybotha/7881691">this gist</a>.</p>

<p><small>All SVG images are 500px x 500px and constrained by the width of their containing divs for a fluid experience.</small></p>


<h2>Viewbox, width, height, preserveAspectRatio</h2>
<p><code>&lt;svg ... viewBox="0 0 500 500" width="500px" height="500px" preserveAspectRatio="xMinYMin meet"&gt;</code></p>
<p>A solution proposed <a href="http://soqr.fr/testsvg/svg-inside-img.php">here</a></p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse-with-viewbox-width-height.svg">
</div>

<hr>


<h2>Viewbox, width, height - default Illustrator output</h2>
<p><code>&lt;svg ... viewBox="0 0 500 500" width="500px" height="500px"&gt;</code></p>
<p>The default output of Illustrator. This is desired, and is what scales as expected on all non-IE browsers.</p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse-with-viewbox-width-height.svg">
</div>

<hr>

<h2>Viewbox Only</h2>
<p><code>&lt;svg ... viewBox="0 0 500 500"&gt;</code></p>
<p>Removing width and height attributes - solution proposed on <a href="http://stackoverflow.com/questions/9777143/svg-in-img-element-proportions-not-respected-in-ie9/9792254#9792254">Stack Overflow</a></p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse-with-viewbox.svg">
</div>

<hr>

<h2>None of the above attributes</h2>
<p><code>&lt;svg ... &gt;</code></p>
<p>Test how browsers behave when none of the attributes used above are applied.</p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse.svg">
</div>
              
            
!

CSS

              
                .constrain {
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid #f2f2f2;
}

/*
 * Ensure an image never exceeds the width of its container
 */
img {
  max-width: 100%;
  height: auto;
}

/*
 * Let's target IE to respect aspect ratios and sizes for img tags containing SVG files
 *
 * [1] IE9
 * [2] IE10+
 */
/*
// 1
img[src*=".svg"] {
  width: 100%\9; 
}
// 2
@media screen and (min-width:0\0) {
  img[src*=".svg"] {
    width: 100%; 
  }
}
*/



/*-------------------------*\
  Prettify
\*-------------------------*/
body {
  color: #666;
  max-width: 600px;
  margin:0 auto;
  padding: 0 2em;
}
              
            
!

JS

              
                
              
            
!
999px

Console