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.

            
              <figure class="responsive-text-align">
  <img src="https://res.cloudinary.com/andykirk/image/upload/v1488115636/nasa/pia20512-1041x398.jpg" alt="Dione" />
  <figcaption>
    <p>
      <strong>
        Chaos at Hyperion: 
      </strong>
      The moon Hyperion tumbles as it orbits Saturn.
    </p>
    <cite>—
      <a href="https://www.nasa.gov/multimedia/imagegallery/iotd.html">NASA</a>
    </cite>
  </figcaption>
</figure>

<figure class="responsive-text-align">
  <img src="https://res.cloudinary.com/andykirk/image/upload/v1488115638/nasa/pia20700.jpg" alt="Artist’s concept shows an unusual celestial object called CX330 " />
  <figcaption>
    <p>
      <strong>
        The Loneliest Young Star: 
      </strong>
      An unusual celestial object called CX330 was first detected as a source of X-ray light in 2009. It has been launching “jets” of material into the gas and dust around it.
    </p>
    <cite>—
      <a href="https://www.nasa.gov/multimedia/imagegallery/iotd.html">NASA</a>
    </cite>
  </figcaption>
</figure>

<p>
  All credit for this idea goes to <a href="http://nocode.in/aligning-text-smartly-in-css/">Vijay Sharma: Aligning Text Smartly in CSS</a>
</p>
            
          
!
            
              /* Basic common settings: */
$primary-color: rgb(0,20,30);
$secondary-color: rgb(151, 81, 0);

*, ::before, ::after {
  box-sizing: border-box;
}

body {
  font-family: 'Lato', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.4;
  padding: 1rem;
  margin: 0;
}


img {
  /* Remove whitespace under images: */
  vertical-align: middle;
  width: 100%;
}

.responsive-text-align a {
  color: $secondary-color;
  &:hover {
    color: lighten($secondary-color, 50);
  }
}

figure {
  padding: 1em;
  margin: 0 0 1em 0;
  background: #eee;
  border: 1px solid #ccc;
}

/* Double last margin prevention hack. Not intended for production. */
p:last-of-type {
  margin-bottom: 0;
}


.responsive-text-align {
  /* Cosmetics (not part of the pattern): */
  background: $primary-color;
  color: #fff;

  padding: 1em;  
  text-align: center;
}

.responsive-text-align p {
  text-align: left;
  display: inline-block;
}

.responsive-text-align cite {
  display: block;
  text-align: left;
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console