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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

              <div class="container absolute-center">   
  <div class="absolute-center is-image">
    <img src="https://natalieolivo.github.io/imgs/girl.jpg"  />
              html, body { height: 100%; margin: 0; }
/* Discovered that this doesn't work if the natural image height extends the height of the container */
body {
  background: pink;

.container {
  background: grey;
  width: 60%;
  height: 40%;
  box-sizing: border-box;

/* this works charmingly for vertical centering
if a variable height is not necessary, since height
needs to be specified */
.absolute-center {
  margin: auto;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
.absolute-center.is-image {
  max-height: 90%;
  background-image: url("https://natalieolivo.github.io/imgs/girl.jpg");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center center;

.absolute-center.is-image img { 
  visibility: hidden;
  display: block;
  width: 100%;
  height: auto;
Loading ..................