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

              
                <!-- the modal -->
(The js code under html codepen tab (scroll))

<section class="remodal" data-remodal-id="modal">
  <button data-remodal-action="close" title="Close" class="remodal-close"></button>
  <div class="video-container" id="responsive-wrapper">
    <div id="player"></div>
  </div>
</section>

<!-- the html -->
<main class="remodal-bg">
  <br>
  <!-- THE BUTTON href=#modal (match data-remodal-id)-->
  <a class="btn btn-primary" href="#modal">
    <img width=55" src="https://upload.wikimedia.org/wikipedia/commons/e/e1/Logo_of_YouTube_%282015-2017%29.svg">                 
    + Show a modal 'node'"
  with <strong>data-remodal-id="modal"</strong> attribute
  </a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <a href="http://vodkabears.github.io/remodal/" target="_blank">
   Remodal site
  </a>

  <br>
  <hr>
  <h5>Related Examples:</h5>
  <ol>
    <li>
      <a target="_blank" href="https://codepen.io/ezra_siton/pen/bjqwjL
      ">
        <stong>HTML5 video</strong>: Remodal + Video js (HTML5 video) - play video when modal is open</a>
    </li>
  </ol>

  <hr>
  <h2>DOCS</h2>

  <p>For your button (<code>&lt;a&gt;</code> tag) add <code>href="#modal"</code> (remember to add "#") for the modal add <code>data-remodal-id="modal"</code> and class <code>remodal</code> - and you ready :)

    <p>The video install by youtube API (put the video inside the hidden modal).</p>
    <p>Copy-paste the CSS to your project (set the video to 16:9 aspect ratio + responsive).</p>
    <p>Youtube autoplay only if you set mute to true (<code>mute:1</code>) - under <code>playerVars</code></p>
    <h5>Before head (copy-paste)</h5>
    <pre>
<code>
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/remodal/1.1.0/remodal.min.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/remodal/1.1.0/remodal-default-theme.min.css&quot;&gt;
 
</code>
 </pre>

    <h5>Before body (copy-paste)</h5>

    <pre>
<code>
/* for now webflow users load jquery first */
&lt;script src=&quot;https://code.jquery.com/jquery-3.3.1.min.js&quot;
  integrity=&quot;sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=&quot;
  crossorigin=&quot;anonymous&quot;&gt;
&lt;/script&gt;
  
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/remodal/1.1.0/remodal.min.js&quot;&gt;&lt;/script&gt;
</code>
 </pre>

    <h4>Install</h4>
    <pre>
<code>
&lt;script&gt;
 var tag = document.createElement(&quot;script&quot;);
  tag.src = &quot;https://www.youtube.com/iframe_api&quot;;
  var firstScriptTag = document.getElementsByTagName(&quot;script&quot;)[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  // 3. This function creates an &lt;iframe&gt; (and YouTube player)
  //    after the API code downloads.
  var player;

  function onYouTubeIframeAPIReady() {
    player = new YT.Player(&quot;player&quot;, {
      height: &quot;100%&quot;,
      width: &quot;100%&quot;,
      videoId: &quot;Xa0Q0J5tOP0&quot;,
      playerVars: {
        autoplay: 1,
        mute: 1,
        controls: 1,
        info: 0,
        showinfo: 0,
        rel: 0,
        modestbranding: 1,
        wmode: &quot;transparent&quot;
      },
      events: {
        onReady: onPlayerReady,
        onStateChange: onPlayerStateChange
      }
    });
  }
  // 4. The API will call this function when the video player is ready.
  function onPlayerReady(event) {
    // event.target.playVideo();  
  }
  // 5. The API calls this function when the player's state changes.
  var done = false;

  function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING &amp;&amp; !done) {
      done = true;
    }
  }

  function stopVideo() {
    player.stopVideo();
  }
  // remodal events //
  $(document).on(&quot;opening&quot;, &quot;.remodal&quot;, function() {
    player.playVideo();
  });
  $(document).on(&quot;closing&quot;, &quot;.remodal&quot;, function(e) {
    player.stopVideo();
  });
&lt;/script&gt;
</code>


</pre>

</main>

<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous">
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/remodal/1.1.0/remodal.min.js"></script>

<script>
  // 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", {
      height: "100%",
      width: "100%",
      videoId: "Xa0Q0J5tOP0",
      playerVars: {
        autoplay: 1,
        mute: 1,
        controls: 1,
        info: 0,
        showinfo: 0,
        rel: 0,
        modestbranding: 1,
        wmode: "transparent"
      },
      events: {
        onReady: onPlayerReady,
        onStateChange: onPlayerStateChange
      }
    });
  }
  // 4. The API will call this function when the video player is ready.
  function onPlayerReady(event) {
    // event.target.playVideo();  
  }
  // 5. The API calls this function when the player's state changes.
  var done = false;

  function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
      done = true;
    }
  }

  function stopVideo() {
    player.stopVideo();
  }
  // remodal events //
  $(document).on("opening", ".remodal", function() {
    player.playVideo();
  });
  $(document).on("closing", ".remodal", function(e) {
    player.stopVideo();
  });
</script>
              
            
!

CSS

              
                body{
  margin: 0 auto;
  padding: 20px; 
}

/*remodal*/
.remodal-wrapper {
    padding: 0px 0px 0;
}

.remodal-close:before{
  left:10px;
}
.remodal{
  max-width: 1450px!important;
  background: transparent!important;
  padding: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  
}
/* remove padding on mobile */
@media only screen and (max-width: 641px){
  .remodal {
      padding: 4px!important;
  }
  /* align close menu on mobile */
  .remodal-close{
    top: -40px;  
  }
}

/* change icon align to left */
.remodal-close{
  right: 0px;
  left: auto;
}

.video-container { 
    position: relative; 
    padding-bottom: 56.25%; 
    padding-top: 30px; 
    height: 0; 
    overflow: hidden; 
   
} 
.video-container iframe, .video-container object, .video-container embed { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
}
              
            
!

JS

              
                
              
            
!
999px

Console