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

              
                <div class="responsive">Resize to view responsiveness. Current view:
</div>
<!-- Skater -->
<picture>
  <!-- Largest Desktop -->
  <source
    media="(min-width: 1280px)"
    sizes="1200px"
    ix-path="unsplash/skater.jpg"
    ix-params='{
      "w": 2048,
      "h": 900,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".4",
      "fp-y": ".35",
      "fp-z": "1"       
    }'
  >
  <!-- Small Desktop -->
  <source
    media="(min-width: 960px)"
    sizes="940px"
    ix-path="unsplash/skater.jpg"
    ix-params='{
      "w": 940,
      "h": 360,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".4",
      "fp-y": ".35",
      "fp-z": "1.5"
    }'
  >
  <!-- Tablet -->
  <source
    media="(min-width: 480px)"
    sizes="calc(100vw - 40px)"
    ix-path="unsplash/skater.jpg"
    ix-params='{
      "w": 640,
      "h": 420,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".4",
      "fp-y": ".35",
      "fp-z": "1.75"
    }'
  >
  <!-- Phone -->
  <source
    sizes="calc(100vw - 40px)"
    ix-path="unsplash/skater.jpg"
    ix-params='{
      "w": 300,
      "h": 300,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".4",
      "fp-y": ".35",
      "fp-z": "2.5"
    }'
  >
  <img ix-path="unsplash/astronaut.jpg">
</picture>
<br>
<!-- Games -->
<picture>
  <!-- Largest Desktop -->
  <source
    media="(min-width: 1280px)"
    sizes="1200px"
    ix-path="unsplash/games.jpg"
    ix-params='{
      "w": 2048,
      "h": 900,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".28",
      "fp-y": ".375",
      "fp-z": "1"   
    }'
  >
  <!-- Small Desktop -->
  <source
    media="(min-width: 960px)"
    sizes="940px"
    ix-path="unsplash/games.jpg"
    ix-params='{
      "w": 940,
      "h": 360,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".28",
      "fp-y": ".375",
      "fp-z": "1.5"
    }'
  >
  <!-- Tablet -->
  <source
    media="(min-width: 480px)"
    sizes="calc(100vw - 40px)"
    ix-path="unsplash/games.jpg"
    ix-params='{
      "w": 640,
      "h": 420,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".28",
      "fp-y": ".375",
      "fp-z": "1.75"
    }'
  >
  <!-- Phone -->
  <source
    sizes="calc(100vw - 40px)"
    ix-path="unsplash/games.jpg"
    ix-params='{
      "w": 300,
      "h": 300,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".28",
      "fp-y": ".375",
      "fp-z": "3"
    }'
  >
  <img ix-path="unsplash/games.jpg">
</picture>
<br>
<!-- Crowd -->
<picture>
  <!-- Largest Desktop -->
  <source
    media="(min-width: 1280px)"
    sizes="1200px"
    ix-path="unsplash/crowd.jpg"
    ix-params='{
      "w": 2048,
      "h": 900,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".12",
      "fp-y": ".435",
      "fp-z": "1"
    }'
  >
  <!-- Small Desktop -->
  <source
    media="(min-width: 960px)"
    sizes="940px"
    ix-path="unsplash/crowd.jpg"
    ix-params='{
      "w": 940,
      "h": 360,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".12",
      "fp-y": ".435",
      "fp-z": "1.5"
    }'
  >
  <!-- Tablet -->
  <source
    media="(min-width: 480px)"
    sizes="calc(100vw - 40px)"
    ix-path="unsplash/crowd.jpg"
    ix-params='{
      "w": 640,
      "h": 420,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".12",
      "fp-y": ".435",
      "fp-z": "1.75"
    }'
  >
  <!-- Phone -->
  <source
    sizes="calc(100vw - 40px)"
    ix-path="unsplash/crowd.jpg"
    ix-params='{
      "w": 300,
      "h": 300,
      "fit": "crop",
      "crop": "focalpoint",
      "fp-x": ".12",
      "fp-y": ".435",
      "fp-z": "2"
    }'
  >
  <img ix-path="unsplash/crowd.jpg">
</picture>
<section class="content">
    <article>
    <h1>Set a custom Focal Point to Crop Photos</h1>
    <h2>Art direction & responsive images with imgix</h2>
    <p>Cropping for editorial generally requires multiple sizes and aspect ratios for each image, to support both multiple uses (hero unit,  thumbnails) and responsive design requirements (square for mobile view, widescreen for desktop). Because all of these are coming from the same original, manually cropping and saving separate files is wasted effort.</p>

<p>Instead, with imgix you can generate every version on-demand to bring the most compelling and relevant parts of the image forward, and then plug those URLs into your responsive breakpoints. Let’s see how this works with some typical editorial-type photos. We’ll go step-by step for each of the crops here—check out the related CodePen to see the underlying responsive HTML and how we’re using imgix.js to generate a complete `srcset` to support any size we might choose in the future.</p>
    <p>Resize this window to view how the images above crop and zoom to display the image best for each viewport size.</p>
  </article> 
</section>
    <div class="button-group">
       <a href="https://www.imgix.com" class="button">Learn More about 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

              
                body{
  padding:0;
  margin:0;
  text-align:center;
}
              
            
!

JS

              
                imgix.config.host = 'assets.imgix.net';
imgix.config.useHttps = true;
              
            
!
999px

Console