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

              
                <div class="responsive">Resize to view responsiveness. Current view:
</div>
<section class="examples">
<picture>
  <source media="(min-width: 1280px)" srcset="https://demos.imgix.net/obama1.jpg?crop=faces,entropy&h=600&w=1200&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=15&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=bottom%2Cleft">
    <source media="(min-width: 768px)" srcset="https://demos.imgix.net/obama1.jpg?crop=faces,entropy&h=600&w=700&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=20&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=15&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft">
    <source media="(min-width: 480px)" srcset="https://demos.imgix.net/obama1.jpg?crop=faces,entropy&h=500&w=320&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=20&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=30&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft">
    <img src="https://demos.imgix.net/obama1.jpg?crop=faces&h=200&w=200&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=10&txtfit=max&markscale=30&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft&rect=.25,.1,.5,.5" alt="The president Walking off of Air Force One">
</picture>
</section>

<section class="examples">
<picture>
  <source media="(min-width: 1200px)" srcset="https://demos.imgix.net/obama2.jpg?crop=faces,entropy&h=600&w=1200&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=15&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=bottom%2Cleft">
    <source media="(min-width: 768px)" srcset="https://demos.imgix.net/obama2.jpg?crop=faces,entropy&h=600&w=700&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=20&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=15&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft">
    <source media="(min-width: 480px)" srcset="https://demos.imgix.net/obama2.jpg?crop=faces,entropy&h=500&w=320&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=20&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=30&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft">
    <img src="https://demos.imgix.net/obama2.jpg?crop=faces&h=200&w=200&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=10&txtfit=max&markscale=30&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft&rect=.25,.1,.5,.5" alt="The president Walking off of Air Force One">
</picture>
  
</section>

<section class="examples">
<picture>
  <source media="(min-width: 1200px)" srcset="https://demos.imgix.net/obama4.jpg?crop=faces,entropy&h=600&w=1200&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=15&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=bottom%2Cleft">
    <source media="(min-width: 768px)" srcset="https://demos.imgix.net/obama4.jpg?crop=faces,entropy&h=600&w=700&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=20&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=15&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft">
    <source media="(min-width: 480px)" srcset="https://demos.imgix.net/obama4.jpg?crop=faces,entropy&h=500&w=320&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=20&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=30&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft">
    <img src="https://demos.imgix.net/obama4.jpg?crop=faces&h=200&w=200&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=10&txtfit=max&markscale=30&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft&rect=.25,.1,.5,.5" alt="The president Walking off of Air Force One">
</picture>
</section>
<section class="content">
  <article>
    <h1>Using picture element with imgix</h1>
    <h2>with a twist of Art Direction</h2>
    <p>The <code>&lt;picture&gt;</code> element when used with imgix can give unprecendented control over the art direction of images on a site to fit a responsive layout. With imgix, it is simple to change width, height, and cropping with automatic face and point-of-interest detection.</p>
    
    <p>Additional elements such as text, and additional compositied items such as watermarks can be added using the imgix API. These can take advantage of rules such as <code>markscale</code>, <code>markalign</code>, <code></codE> that can impact how the composite image is made up.</p>
    <p>In this example, as you resize the page, you will see how a watermark and simple text is adjusted accordingly to the image's size. Using imgix, these can be adjusted right in the picture element. </p>
    
    <p>You can compose images using our <a href="https://sandbox.imgix.com" target="_blank">Sandbox</a>. Here is an example of how we can compose an image to figure out how to include it for our picture element.</p>
    <figure>
      <img src="https://demos.imgix.net/obama1.jpg?txtshad=10&crop=faces&h=400&w=640&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=25&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft" alt="Vi demonstrating multiple devices">
      <pre class="single-line sandbox">
        <a href="https://sandbox.imgix.com/view?url=https%3A%2F%2Fdemos.imgix.net%2Fobama1.jpg%3Fmarkalign%3Dtop%252Cleft%26mark%3Dhttps%253A%252F%252Fassets.imgix.net%252Fpresskit%252Fimgix-presskit.pdf%253Fpage%253D6%2526fm%253Dpng%2526w%253D640%26markscale%3D25%26txtfit%3Dmax%26txtpad%3D20%26txtsize%3D24%26txtclr%3Dffffff%26txtfont%3DAvenir%2BNext%2BMedium%26markpad%3D10%26txt%3DGage%2BSkidmore%2B%252F%2BIndependent%26fit%3Dcrop%26w%3D640%26h%3D400%26crop%3Dfaces%26txtshad%3D10" class="sandbox-link" title="View in Sandbox" target="_blank">View in Sandbox</a>
        <code> https://demos.imgix.net/obama1.jpg?txtshad=10&crop=faces&h=400&w=400&fit=crop&txt=Gage+Skidmore+%2F+Independent&markpad=10&txtshad=10&txtfont=Avenir+Next+Medium&txtclr=ffffff&txtsize=24&txtpad=20&txtfit=max&markscale=25&mark=https%3A%2F%2Fassets.imgix.net%2Fpresskit%2Fimgix-presskit.pdf%3Fpage%3D6%26fm%3Dpng%26w%3D640&markalign=top%2Cleft</code>
      </pre>
        <figcaption> An example of a composited image using imgix.</figcaption>
    </figure>
         
    <div class="button-group">
       <a href="https://docs.imgix.com/tutorials/using-imgix-picture-element" class="button">View picture element Tutorial</a>
       <a href="https://imgix.com" class="button">Visit imgix</a>
    </div>
  </article> 
</section>
<footer>
  <hr>
<a href="https://imgix.com"><img src="https://assets.imgix.net/presskit/imgix-presskit.pdf?page=3&fm=png&w=320&dpr=2" width="160" height="60"></a>
</footer>
              
            
!

CSS

              
                section.examples{
  padding-top:0;
  text-align:center;
}
              
            
!

JS

              
                
              
            
!
999px

Console