Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Responsive Video or Slideshow Embeds in Bootstrap with Examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Bootstrap allows creating responsive video or slideshow embeds based on the width of the display or parent element by creating a native ratio that scales with the device. Using responsive video or slideshow embeds the content can be scaled automatically as per the screen size or the parent container element, this makes the UI more responsive.

Bootstrap provides a class named embed-responsive for creating responsive embeds. This class is assigned to the parent which encloses any of the following embedding elements: <iframe>, <embed>, <video>, and <object>.

Optionally, along with the embed-responsive class, one more class embed-responsive-item can be used with the embedding elements.

Bootstrap also provides a few modifier classes to adjust the aspect ratio of the elements:

  • embed-responsive-16by9
  • embed-responsive-21by9
  • embed-responsive-1by1
  • embed-responsive-4by3

Below program illustrate the embed-responsive class:




<!DOCTYPE html>
<html>
<head>
    <!-- Link Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
      
    <title>
        Responsive Video
    </title>
</head>
  
<body>
    <div class="embed-responsive 
                embed-responsive-21by9">
        <iframe class="embed-responsive-item" 
                src="https://www.youtube.com/embed/HMAwoMt3kek" 
                allowfullscreen>
        </iframe>
    </div>
</body>
</html>                    

Output:

My Personal Notes arrow_drop_up
Last Updated : 24 Jan, 2019
Like Article
Save Article
Similar Reads
Related Tutorials