cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

              <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 class="player__container">
    <div class="overlay"></div>
    <div id="player"></div>


$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

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

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

    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)
  position: absolute
  padding: 2em
  height: 100%
  width: 100%
  z-index: 3
h1, p
  text-align: center
  color: white
  font-size: 2.2em
  font-weight: 300
  text-transform: uppercase
  width: 100%
  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) {
  // disable audio

Loading ..................