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.

            
              <header class="header" role="banner">
  <h1>Flexbox YouTube Thumbnail Grid</h1>
</header>
<main role="main">
  <article>
    <p>Responsive flexbox unordered list grid of YouTube video thumbnails with Fancybox links. Uses a 9kb image with a 16:9 aspect ratio to be able to use the YouTube thumbnails as a background image, without seeing those black letterbox bars at the top and bottom. This also makes the video thumbnails fluid when resizing the browser.</p>
  </article>
  <section class="videos" id="featured-videos">
    <div class="video-grid front-page" id="front-page-videos">
      <ul class="video-list featured">
        <li class="video featured">
          <a data-fancybox href="https://www.youtube.com/embed/Zq6Crtglztk?autoplay=1&controls=0&showinfo=0&color=white&rel=0" class="featured-video">
            <figure style="background-image: url(https://img.youtube.com/vi/Zq6Crtglztk/hqdefault.jpg);">
              <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/50598/video-thumb-placeholder-16-9.png" />
              <figcaption>Swap-Meet Speed for Roadkill Nights</figcaption>
            </figure>
          </a>
        </li>
        <li class="video featured">
          <a data-fancybox href="https://www.youtube.com/embed/qDK86kzgUPg?autoplay=1&controls=0&showinfo=0&color=white&rel=0" class="featured-video">
            <figure style="background-image: url(https://img.youtube.com/vi/qDK86kzgUPg/hqdefault.jpg);">
              <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/50598/video-thumb-placeholder-16-9.png" />
              <figcaption>Cummins Diesel in a Cadillac</figcaption>
            </figure>
          </a>
        </li>
        <li class="video featured">
          <a data-fancybox href="https://www.youtube.com/embed/uSB2_428P2w?autoplay=1&controls=0&showinfo=0&color=white&rel=0" class="featured-video">
            <figure style="background-image: url(https://img.youtube.com/vi/uSB2_428P2w/hqdefault.jpg);">
              <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/50598/video-thumb-placeholder-16-9.png" />
              <figcaption>Dirt-Track Challenger Rescue and Thrash</figcaption>
            </figure>
          </a>
        </li>
        <li class="video featured">
          <a data-fancybox href="https://www.youtube.com/embed/pOhl6oVpEes?autoplay=1&controls=0&showinfo=0&color=white&rel=0" class="featured-video">
            <figure style="background-image: url(https://img.youtube.com/vi/pOhl6oVpEes/hqdefault.jpg);">
              <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/50598/video-thumb-placeholder-16-9.png" />
              <figcaption>Junkyard 1956 Buick Hack</figcaption>
            </figure>
          </a>
        </li>
        <li class="video featured">
          <a data-fancybox href="https://www.youtube.com/embed/PVs_xZ46Cxw?autoplay=1&controls=0&showinfo=0&color=white&rel=0" class="featured-video">
            <figure style="background-image: url(https://img.youtube.com/vi/PVs_xZ46Cxw/hqdefault.jpg);">
              <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/50598/video-thumb-placeholder-16-9.png" />
              <figcaption>Wheelstanding Dump Truck! Stubby Bob’s Comeback</figcaption>
            </figure>
          </a>
        </li>
        <li class="video featured">
          <a data-fancybox href="https://www.youtube.com/embed/C4jk51rgfts?autoplay=1&controls=0&showinfo=0&color=white&rel=0" class="featured-video">
            <figure style="background-image: url(https://img.youtube.com/vi/C4jk51rgfts/hqdefault.jpg);">
              <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/50598/video-thumb-placeholder-16-9.png" />
              <figcaption>Will It Go 10s? Mazdarati Is Back!</figcaption>
            </figure>
          </a>
        </li>
      </ul>
    </div
  </section>
</main>
            
          
!
            
              /**
 * Grid styles
 */
.video-grid.front-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1em 2em;
}

ul.video-list {
  display: flexbox;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

li.video {
  flex-grow: 1;
  position: relative;
  ooverflow: hidden;
	width: 33.333333333%;
	width: -webkit-calc(100% / 3);
	width: calc(100% / 3);
  border: solid 0.2em transparent;
  
  & a {
    outline: none;
  }
      
  &:before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0);
    transition: background-color .15s;
  }
  
  & figure {
    display: block;
    position: relative;
    overflow: hidden;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    
    & img {
      display: block;
      max-width: 100%;
      height: auto;
      opacity: 0;
      transform: scale(0.5);
      transition: all .20s;
    }

    & figcaption {
      position: absolute;
      bottom: 0;
      width: 100%;
      background: rgba(0,0,0,0.6);
      color: #fff;
      font-size: 1.4rem;
      font-weight: 600;
      padding: 1rem;
      transform: translateY(0);
      opacity: 1;
      transition: all .20s;
    }
  }
  
  &:hover {
    & figure {
      & img {
        opacity: 1;
        transform: scale(1);
      }
      
      & figcaption {
        opacity: 0;
        transform: translateY(50%);
      }
    }
  }
  
  &:hover:before {
    background-color: rgba(0,0,0,0.3);
  }
}

@media screen and (max-width: 800px) {
	li.video {
		width: 50%;
		width: -webkit-calc(100% / 2);
		width: calc(100% / 2);
	}
}

@media screen and (max-width: 640px) {
	li.video {
		width: 100%;
	}
}

/**
 * Pen styles
 */
html { box-sizing: border-box; height: 100%; overflow-y: scroll; font-size: 62.5%; }
*, *:before, *:after { box-sizing: inherit; }
body {
	background: #fff;
	color: #444;
	font-family: 'Open Sans', Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
	font-size: 1.8rem;
	line-height: 1.2;
}

header {
  width: 100%;
  padding: 2em;
  box-shadow: 0px 0px 10px rgba(0,0,0,0.7);
  
  & h1 {
    font-size: 3rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.03em;
    color: #666;
  }
}

main {
  padding: 2rem 0;
}

article {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1em 2em;
}
            
          
!
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