Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

              
                  <body>
    <div id="player-size" style="">
      <div id="cropping-div" style="">
        <div id="div-to-crop" style="">
          <div id="player-wrapper">
            <!-- 1. The <iframe> (and video 
            player) will replace this <div> 
            tag. -->
            <div id="player"></div>
          </div>
        </div>
      </div>
    </div>
    <table style="border: 0; width: 310px;">
      <tbody>
        <tr style="background: #fff;">
          <td>
            <label for="videoId-property">videoId: </label>
            <input type="text" id="videoId" style="width: 100px"><br>
          </td>

          <td style="">
            <button id="videoId-properties" onclick="updateVideoId()">Update Player</button>
          </td>
        </tr>
      </tbody>
    </table>
  </body>

  </html>
              
            
!

CSS

              
                #player-size {
  /* comment below line for responsive 16:9 full screen */
  width: 640px;
  /* only need to specify width since 16:9 ratio is  
     preserved / automatically applied */
}

#cropping-div {
  overflow: hidden;
}

#div-to-crop {
  overflow: hidden;
  margin-top: -51%;
  margin-bottom: -20%;
}

#player-wrapper {
  position: relative;
  overflow: hidden;
  padding-top: 128.25%;
}

#player {
  position: absolute;
  top: 0;
  width: 100%;
  height: 124%;
  
}

table {
    border: 0;
    border-collapse: collapse;
    border-spacing: 0;
    font: 14px/20px Noto Sans Bengali,sans-serif;
    margin: 16px 0 15px;
    width: 100%;
}


              
            
!

JS

              
                // 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement("script");

tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
var player;

function onYouTubeIframeAPIReady() {
  player = new YT.Player("player", {
    host: "https://www.youtube.com",
    /* no need to specify player 
    size here since it is handled 
    by the player-size div */
    videoId: "dlFA0Zq1k2A",
    playerVars: {
      enablejsapi: 1,
      playsinline: 1,
      start: 0,
      disablekb: 0
    },
    events: {
      onStateChange: onPlayerStateChange
    }
  });
}

function onPlayerStateChange(event) {
  console.log("player state: " + player.getPlayerState());
}

function updateVideoId() {
  let videoId = document.getElementById("videoId").value;
  player.loadVideoById(videoId, -1);
}

function stopVideo() {
  player.stopVideo();
}

              
            
!
999px

Console