Bootstrap 4 - Embed

The embed utility is used to insert a video in a page by using <iframe> element along with .embed-responsive class and an aspect ratio (for instance: embed-responsive-21by9).
You can use the aspect ratios such as 21by9, 16by9, 4by3, 1by1to embed video in a page. The following example demonstrates this −
<html lang = "en">
   <head>
      <!-- Meta tags -->
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
      
      <!-- Bootstrap CSS -->
      <link rel = "stylesheet" 
         href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container">
         <h2>Aspect Ratios</h2>
         <h4>21:9 aspect ratio</h4>
         <div class = "embed-responsive embed-responsive-21by9">
            <iframe class = "embed-responsive-item" 
            src = "https://www.youtube.com/embed/I_G0Yb6R7m0" allowfullscreen></iframe>
         </div>
         <br>
         
         <h4>16:9 aspect ratio</h4>
         <div class = "embed-responsive embed-responsive-16by9">
            <iframe class = "embed-responsive-item" 
               src = "https://www.youtube.com/embed/I_G0Yb6R7m0"></iframe>
         </div>
         <br>
         
         <h4>4:3 aspect ratio</h4>
         <div class = "embed-responsive embed-responsive-4by3">
            <iframe class = "embed-responsive-item" 
               src = "https://www.youtube.com/embed/I_G0Yb6R7m0"></iframe>
         </div>
         <br>
         
         <h4>1:1 aspect ratio</h4>
         <div class = "embed-responsive embed-responsive-1by1">
            <iframe class = "embed-responsive-item" 
               src = "https://www.youtube.com/embed/I_G0Yb6R7m0"></iframe>
         </div>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src =" https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity =" sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>
It will produce the following result −

    26 Lectures 
     2 hours 

 Anadi Sharma

    54 Lectures 
     4.5 hours 

 Frahaan Hussain

    161 Lectures 
     14.5 hours 

 Eduonix Learning Solutions

    20 Lectures 
     4 hours 

 Azaz Patel

    15 Lectures 
     1.5 hours 

 Muhammad Ismail

    62 Lectures 
     8 hours 

 Yossef Ayman Zedan
 Print
 Add Notes
 Bookmark this page