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

              
                <article>
  <figure class="center-split">
    <img src="https://source.unsplash.com/Sfs_64L9UHE/500x300" srcset="https://source.unsplash.com/Sfs_64L9UHE/500x300 500w,
                   https://source.unsplash.com/Sfs_64L9UHE/1000x600 1000w,
                   https://source.unsplash.com/Sfs_64L9UHE/1500x900 1500w,
                   https://source.unsplash.com/Sfs_64L9UHE/2000x1200 1000w" alt="The golden light of the setting sun illuminates the Valle de la Luna in the Atacama Desert, Chile" />
    <figcaption>
      <h1>Equal center split layout</h1>
      <p>Each item of <code>.center-split</code> is 50% wide. The content within is sized with the <code>--center-split-max-width</code> Custom Property. Inner content in all items is pushed into the center.</p>
    </figcaption>
  </figure>
  <figure class="center-split">
    <figcaption>
      <p>Nullam quis risus eget urna mollis ornare vel eu leo. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nulla vitae elit libero, a pharetra augue. Curabitur blandit tempus porttitor. Nulla vitae elit libero, a pharetra
        augue. Donec id elit non mi porta gravida at eget metus. Sed posuere consectetur est at lobortis.</p>
    </figcaption>
    <img src="https://source.unsplash.com/VJTmFSendQ0/500x300" srcset="https://source.unsplash.com/VJTmFSendQ0/500x300 500w,
                   https://source.unsplash.com/VJTmFSendQ0/1000x500 1000w,
                   https://source.unsplash.com/VJTmFSendQ0/1500x900 1500w,
                   https://source.unsplash.com/VJTmFSendQ0/2000x1200 1000w" alt="Sunset behind a big-ass mountain" />
  </figure>
  <figure class="center-split">
    <img src="https://source.unsplash.com/hGgd46qq3ww/500x300" srcset="https://source.unsplash.com/hGgd46qq3ww/500x300 500w,
                   https://source.unsplash.com/hGgd46qq3ww/1000x500 1000w,
                   https://source.unsplash.com/hGgd46qq3ww/1500x900 1500w,
                   https://source.unsplash.com/hGgd46qq3ww/2000x1200 1000w" alt="Sunset behind a big-ass mountain" />
    <figcaption>
      <p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla sed consectetur. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis in, egestas
        eget quam. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>
    </figcaption>
  </figure>
</article>
              
            
!

CSS

              
                .center-split {
  --center-split-max-width: 30vw;
}

/* So that content vertically aligns, we set it as a flex item */
.center-split > * {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem;
}

/* Reset flex and padding rules for media elements because
   we want them to bleed out */
.center-split > img,
.center-split > picture,
.center-split > video {
  display: block;
  padding: 0;
  
  /* Stuff is gonna get stretchy, so maintain 
     some order and crop media */
  object-fit: cover;
}

@media (min-width: 720px) {
  .center-split {
    display: grid;
    grid-template-columns: repeat(2, 50%);
    align-items: stretch;
  }
  
  /* Apply our max width to the 
     direct child of the .center-split child */
  .center-split > * > * {
    max-width: var(--center-split-max-width);
  }
  
  /* Set auto margins to push the content into the center */
  .center-split > *:nth-child(odd) > * {
    margin: 0 0 0 auto;
  }
  
  .center-split > *:nth-child(even) > * {
    margin: 0 auto 0 0;
  }
  
  /* Reset max width and margin rules for media elements because
     we want them to bleed out */
  .center-split > img,
  .center-split > picture,
  .center-split > video {
    max-width: 100%;
    margin: 0;
  }
}











/* Presentational styles for this demo */
.center-split {
  color: #141414;
  font-size: 1.35rem;
}

.center-split {
  background: #dddddd;
}


.center-split img {
  filter: saturate(75%);
}



/* Global presentational styles */

body {
  background: #efefef;
  color: #262322;
  line-height: 1.6;
  font-family: Georgia, serif;
}

h1, h2 {
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.1;
  width: 100%;
}

h1 {
  color: #254e70;
  font-size: 2.5rem;
  max-width: 30ch;
  padding-bottom: 1.5rem;
}

h2 {
  font-size: 2rem;
}

article > p {
  font-size: 1.2rem;
  max-width: 60ch;
  margin: 1rem 0 2rem 0;
}

@media (min-width: 720px) {
  article > h1,
  article > p {
    margin-left: 3rem;
  }
}

code {
  font-size: 1.2em;
  border: 1px solid #c1c1c1;
  white-space: pre;
  padding: 2px;
  font-weight: 700;
}

              
            
!

JS

              
                
              
            
!
999px

Console