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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 or require. We'll also process your JavaScript with Babel.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

            
              <div class="container">
  
  <div class="text__container">
    <h1>YouTube Video Background</h1>
    <p>Using the YouTube iFrame Player API,
       <br /> Does not work on iOS :(</p>
  </div>
  
  <div class="player__container">
    <div class="overlay"></div>
    <div id="player"></div>
  </div>
</div>



            
          
!
            
              $bg_pattern: ' data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAATklEQVQYV2NkYGAwZmBgOMuAACA+CKCIMSIpADGRNaEYgKwQ3WQUjTCF6CYhWw2WAynEpgjmIpg7jUlSiM0TWK2GWUOUZ7ApxggeogIcABHJFtfoX9tJAAAAAElFTkSuQmCC'

$bg_image: 'https://i.ytimg.com/vi/1kKkRtVlwrM/maxresdefault.jpg'

$font_family: Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT", "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif

*
  box-sizing: border-box

body
  margin: 0
  font-family: $font_family
  background-color: black
  background-image: url($bg_image)
  background-repeat: no-repeat
  background-size: cover cover
  height: 100%
  
  
.container
  max-height: 400px
  margin: 0 auto
  margin-top: 2em
  position: relative
  overflow: hidden
  width: 80%
  border: 6px solid rgba(#eee, .4)

  
.player__container
  position: relative
  padding-bottom: 56.25%
  height: 0
  overflow: hidden
  max-width: 100%

  .overlay
    height: 100%
    width: 100%
    display: block
    z-index: 1
    position: absolute
    background-color: rgba(blue, .2)
    background-repeat: repeat
    //background-image: url($bg_pattern) 
  
    
  iframe, embed, object
    position: absolute
    top: 0
    left: 0
    width: 100%
    height: 100%
    z-index: -99
    //transform: translateY(-200px)
    
    
.text__container
  position: absolute
  padding: 2em
  height: 100%
  width: 100%
  z-index: 3
  
    
h1, p
  text-align: center
  color: white
  
  
h1
  font-size: 2.2em
  font-weight: 300
  text-transform: uppercase
  width: 100%
  
  
p
  font-size: 1.1em
  border: 3px solid rgba(white, .1)
  background-color: rgba(white ,.1)
  width: 40%
  min-width: 360px
  padding: 1em 2em
  margin: 0 auto
  
  
            
          
!
            
              // https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player

var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";

var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

var player;
function onYouTubeIframeAPIReady() {
  player = new YT.Player('player', {
    height: '390',
    width: '640',
    videoId: 'KL6jwnIln6w',
    playerVars: {
      autoplay: 1,
      autohide: 1,
      controls: 0,
      iv_load_policy: 3,
      fs: 0,
      loop: 1,
      mute: 1,
      showinfo: 0,
      modestbrangin: 1,
    },
    events: {
      'onReady': onPlayerReady,
      'onStateChange': onPlayerReady
    }
  });
}


function onPlayerReady(event) {
  event.target.playVideo();
  
  // disable audio
  player.mute();
}

            
          
!
999px

Console