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 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

Packages

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.

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

              
                <main>
   <h1>
      display: contents
   </h1>

   <div class="article flex flex-column md--flex-row p-4 md--p-6 border-radius-base bg-mono-white box-shadow-2">
      <div class="article__text-content">
         <h2 class="article__title mt-0 mb-2">
            <a href="javascript:void(0);">
               Article Title
            </a>
         </h2>
         <p class="article__author font-weight-bold">
            By Random McLorem
         </p>
         <p>
            I suppose this article should be about something. Let's say it's about pancakes and Pokemon. Would pancakes shaped as Pokemon count?
         </p>
      </div>

      <img class="article__image" src="https://safebooru.org//samples/3508/sample_27e7252d7702849d394847bc3db298f52f411497.jpg?3649363" alt="An image of a Pokemon trainer smiling, winking, and giving a peace sign.">
   </div>

   <p class="mt-6">
      All the text elements in this article component are grouped under the same <code>div</code> element. But on smaller screens, I can use flex to reorder the image among the text elements like they're not grouped at all!
   </p>
</main>
              
            
!

CSS

              
                // Base Styles
* {
   box-sizing: border-box;
}

html,
body {
   color: var(--color-mono-black);

   // background-color: var(--color-primary-light);
}

body {
   min-height: 100vh;
   padding: var(--spacing-4);

   background: linear-gradient(
      135deg,
      var(--color-mono-white),
      var(--color-mono-muted),
      var(--color-primary-light)
   );
}

main {
   margin-right: auto;
   margin-left: auto;
   width: clamp(400px, 75vw, 750px);
   max-width: 100%;
}

a {
   color: var(--color-action-base);
}

// Map for the breakpoints and max width
$breakpoint-map: (
   sm: 480px,
   md: 625px,
   lg: 750px,
   xl: 900px,
   xxl: 1000px
);

@mixin larger-than($point-name) {
   $width: map-get($breakpoint-map, $point-name);
   @media (min-width: $width) {
      @content;
   }
}

@mixin smaller-than($point-name) {
   $width: map-get($breakpoint-map, $point-name);
   @media (max-width: $width) {
      @content;
   }
}

// Custom styles here!
.article {
   gap: 0 var(--spacing-12);

   overflow: hidden;
}

.article__text-content {
   display: contents;
   flex: 1 1 auto;

   @include larger-than(md) {
      display: block;
   }

   *:last-child {
      margin-bottom: 0;
   }
}

.article__image {
   min-width: 125%;
   margin: 0 calc(var(--spacing-6) * -1) var(--spacing-4)
      calc(var(--spacing-6) * -1);
   // flex: 1 1 auto;
   aspect-ratio: 16 / 9;
   object-fit: cover;
   object-position: 50% 25%;

   @include larger-than(md) {
      margin: calc(var(--spacing-6) * -1);
      width: clamp(200px, 25vw, 275px);
      min-width: auto;

      aspect-ratio: 3 / 2;
   }
}

@include smaller-than(md) {
   .article__title,
   .article__author,
   .article__image {
      order: -1;
   }
}

              
            
!

JS

              
                
              
            
!
999px

Console