css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <header>
  <h1>Poor Man's Container Queries</h1>
  <p>Hide content based on the width of its container. Reduce the window size to see how content hides when its container shrinks below a certain width.</p>
</header>

<main>
  <div class="grid">
    <div class="grid__item width-6/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1449586919022-f3dfddc48a71?ixlib=rb-0.3.5&s=ba1ea33955d2ff7ff802b36a8a2cada1&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>

    <div class="grid__item width-6/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1524261644243-e00b1c5f46f5?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=3adfbf9e8447c7aca04fa55a5c4563a0&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>

    <div class="grid__item width-4/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1522387026079-bd4a4d73115d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bab7386b1cbe55eae171863d6680b8b8&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>

    <div class="grid__item width-8/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1494412651409-8963ce7935a7?ixlib=rb-0.3.5&s=8f7c2e4be6212457dd4589b9b3dc0707&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>

    <div class="grid__item width-4/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1493946740644-2d8a1f1a6aff?ixlib=rb-0.3.5&s=cdccc12f5c66e4fe984f2646348bb23c&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>

    <div class="grid__item width-4/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1465844880937-7c02addc633b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=ebbbf0d6640931eac2bca214d6796a86&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>

    <div class="grid__item width-4/12@m">
      <div class="media">
        <div class="media__figure">
          <img src="https://images.unsplash.com/photo-1494412552100-42e4e7a74ec6?ixlib=rb-0.3.5&s=8a20e02f385f4d8be42eae3a39dd7e46&auto=format&fit=crop&w=200&h=143&q=80">
        </div>
        <div class="media__body">
          <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
        </div>
      </div>
    </div>
  </div>
</main>
            
          
!
            
              // ESSENTIAL MAGIC

.media {
  display: flex;
}

.media__figure {
  $container-min-width: 25em;

  // 100% is relative to the container (`.media`)
  // if 100% container width minus `$container-min-width`
  // is equal to or less than 0, the `max-width` is 0 or
  // negative which makes the element disappear.
  // By multiplying the result of the calculation by a very
  // large number, we make sure that the value for `max-width`
  // is larger than the actual width of the element as long as
  // 100% - $container-min-width > 0.
  max-width: calc((100% - #{$container-min-width}) * 9999);
}

.media__body {
  // Make the element take all the available space...
  flex-grow: 1;
  // ... but not at the cost of shrinking `.media__figure`.
  flex-basis: 0;
}

// OPTIONAL STYLING

.media {
  height: 100%;
  border: 1px solid #efefef;
  border-radius: 0.25em;
  overflow: hidden;
  box-shadow: 0 0.25em 0.5em rgba(#444, 0.1);
}

.media__body {
  padding: 1em;
}

// GRID

.grid {
  margin-left: -1.5em;
  margin-top: -1.5em;
  display: flex;
  flex-wrap: wrap;
}

.grid__item {
  padding-left: 1.5em;
  padding-top: 1.5em;
  flex-grow: 1;
}

.width-4\/12\@m {
  @media (min-width: 42em) {
    width: 33.33333%;
  }
}

.width-6\/12\@m {
  @media (min-width: 42em) {
    width: 50%;
  }
}

.width-8\/12\@m {
  @media (min-width: 42em) {
    width: 66.666666%;
  }
}

// MISC

* {
  box-sizing: border-box;
}

body {
  max-width: 84em;
  margin: 0 auto;
  padding: 3em 1em;
  font-family: 'Karla', sans-serif;
  line-height: 1.4;
}

header {
  max-width: 42em;
  margin: 0 auto;
  text-align: center;
  font-size: 1.2em;
}

main {
  margin-top: 3em;
}

h1 {
  font-family: 'Rubik', sans-serif;
  font-weight: 500;
  line-height: 1.2;
  font-size: 2em;
}

p {
  &:not(:first-child) {
    margin-top: 1em;
  }
}

img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  vertical-align: middle;
}
            
          
!
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.
Loading ..................

Console