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

              
                <h2>
   Scroll down to see all the examples, and make sure to resize the page to see how the video backgrounds adapt.
</h2>

<div class="example video-bg">
  <div class="video cover align-center align-middle">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      1. Cover with align-center and align-middle
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video cover align-right align-top">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      2. Cover with align-right and align-top
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video cover align-left align-bottom">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      3. Cover with align-left and align-bottom
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video contain align-center align-middle">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      4. Contain with align-center and align-middle
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video contain align-left align-top">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      5. Contain with align-left and align-top
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video contain align-right align-bottom">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      6. Contain with align-right and align-bottom
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video contain align-right fill-height">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content">
    <h1>
      7. Contain with align-right and fill-height
    </h1>
  </div>
</div>

<div class="example video-bg">
  <div class="video contain align-top fill-width">
    <video width="560" height="320" preload="auto">
      <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    </video>
  </div>
  <div class="content" style="min-height: 600px;">
    <h1>
      8. Contain with align-top and fill-width
    </h1>
  </div>
</div>
              
            
!

CSS

              
                .example {
  border: 1px solid black;
  background-color: #ccc;
  & + .example {
    margin-top: 20px;
  }
  .content {
    position: relative;
    min-height: 400px;
    text-align: center;
    color: white;
  }
}


/* VIDEO BACKGROUND MODULE */

$video-width: 560px;
$video-height: 320px;

.video-bg {
  position: relative;
  overflow: hidden;
  .video {
    &.cover {
      min-height: calc(100% + 2px);
      position: absolute;
      left: -1px;
      right: -1px;
      &::before {
        content: "";
        display: block;
        height: 0px;
        padding-bottom: ($video-height / $video-width * 100) + 0%;
      }
      video {
        width: auto;
        height: 100%;
        position: absolute;
        top: 0px;
      }
      &.align-left video {
        left: 0px;
      }
      &.align-center video {
        left: 50%;
        top: 0px;
        transform: translate(-50%, 0%);
      }
      &.align-right video {
        right: 0px;
      }
      &.align-top {
        top: 0px;
      }
      &.align-middle {
        top: 50%;
        transform: translate(0%, -50%);
      }
      &.align-bottom {
        bottom: 0px;
      }
    }
    &.contain {
      position: absolute;
      left: -1px;
      right: -1px;
      top: -1px;
      bottom: -1px;
      video {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 100%;
        position: absolute;
      }
      &.align-left video {
        left: 0px;
      }
      &.align-center video {
        left: 0px;
        right: 0px;
        margin: auto;
      }
      &.align-right video {
        right: 0px;
      }
      &.align-top video {
        top: 0px;
      }
      &.align-middle video {
        top: 0px;
        bottom: 0px;
        margin: auto;
      }
      &.align-bottom video {
        bottom: 0px;
      }
      &.fill-width video {
        width: 100%;
        max-height: none;
      }
      &.fill-height video {
        max-width: none;
        height: 100%;
      }
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console