cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <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+ (desktop & mobile) 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.  If you want a long-form explaination, it is best to visit <a href=http://triangle717.wordpress.com/2014/06/07/ie-inkscape-svg/>Triangle717's "Internet Explorer and Inkscape SVGs"</a>.</p>

<p>One of the resolutions is to force IE to expand <code>img</code> tags containing SVG images to the desired exact (max-)width.  This is not always desired, but does at least get IE to behave itself with ratio'd scaling.  Using `max-width: 100%;` percentages do <b>not</b> work in IE when browser is not resized (normal size); the image will fill the entire contraining box (600px in this case).</p>

<p><strong>Comment or edit the media query</strong> in the CSS to view 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 id=preserveaspectratio>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 id=viewbox-width-height>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 id=width-height>Width & height only - default Inkscape output</h2>
<p><code>&lt;svg ... width="500px" height="500px"&gt;</code></p>
<p>To help with a <a href="https://github.com/twitter/twemoji/issues/27">bug report</a></p>
<div class="constrain">
  <img src="https://tombyrer.github.io/svg-placeholders/fixate-inverse-with-width-height.svg">
</div>

<hr>

<h2 id=viewbox>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 id=none>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>
            
          
!
            
              .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: 500px\9; 
}
// 2
@media screen and (min-width:0\0) {
  img[src*=".svg"] {
    width: 500px; 
  }
}



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

Console