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. 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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 <a href=https://github.com/twitter/twemoji>twemoji</a> Via Container</h1>

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

<p>Inspired/forked from Larry Botha's Pen: <a href=https://codepen.io/larrybotha/pen/hmlAs/>Test Scaling Of SVG Images In Fluid Layouts</a>.

<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.</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=width-height>Width, height, & viewbox</h2>
<p><code>&lt;svg ... width="47.5" height="47.5" viewBox="0 0 47.5 47.5" style="enable-background:new 0 0 47.5 47.5;" &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://rawgit.com/tomByrer/98b1f169da2dbfb77e1f/raw/6ba886b529a7b9be34c37bc4f55db898b4fe27e9/twemoji-1f63b-widthheight.svg">
</div>

<hr>

<h2 id=width-height>Width & height only - original default Inkscape output</h2>
<p><code>&lt;svg ... width="47.5" height="47.5"&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://rawgit.com/twitter/twemoji/5c0297d324666fbbd2715e50003d5814badac5c4/svg/1f63b.svg">
</div>

<hr>

<h2 id=viewbox>Viewbox + <code>enable-background:new</code> Only</h2>
<p><code>&lt;svg ... viewBox="0 0 47.5 47.5" style="enable-background:new 0 0 47.5 47.5;"&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://rawgit.com/twitter/twemoji/2501eaa1aca1f1793e1171ee98aff30f2529e213/svg/1f63b.svg">
</div>

<hr>

              
            
!

CSS

              
                .constrain {
  width: 500px;
  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 {
  font-family: Arial;
  color: #666;
  max-width: 600px;
  margin:0 auto;
  padding: 0 2em;
}
              
            
!

JS

              
                
              
            
!
999px

Console