123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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>
            
          
!
            
              .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;
}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console