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.

+ add another resource


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


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.


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.


                <div class="images">
  <div class="image">
    <img src=""/>
  <div class="image">
    <img src=""/>
  <div class="image">
    <img src=""/>
  <div class="image">
    <img src=""/>
  <div class="clear-fix"></div>



                @import compass

/* Variables */
$width: 620px
$gap: 20px

$max-width: (($width - 3 * $gap) / 3)
$max-height: $max-width / 3 * 2

/* Basic stuff */
  background: #111
  margin: 0
  clear: both

/* Not so important */
  width: $width
  padding: $gap 0 0 $gap
  background: white
  margin: $gap auto
    margin: 0 $gap $gap 0
    float: left
    box-shadow: 0 0 1px black
    /** Interesting part starts here **/

    font-size: 0
    text-align: center 
    width: $max-width
    height: $max-height
      display: inline-block
      vertical-align: middle
      max-height: 100%
      max-width: 100%

      content: ''
      display: inline-block
      vertical-align: middle
      height: 100%

/* Dmitry Filimonov 2013 */



This is an example of how you can center an image with unknown size inside a div.

It's written in pure CSS, without any JS code.
It can handle images of any size and any orientation.

My name is Dmitry Filimonov and I like creating stuff for web. Follow me on Twitter: