Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap responsive embed not working as expected

embedding video in grid system of Bootstrap 3.1, video is not expanding full width of the grid column. How to make it 100% wide to the parent column keeping the aspect ratio? Also, even if I use a 4:3 video, it appears very wide in the browser with very short height. here is my code:

<div class="row">
   <div class="col-md-8">
   .
   <!-- other items-->
   .
   </div>

   <div class="col-md-4">
            <div class="embed-responsive embed-responsive-4by3">
                            <iframe class="embed-responsive-item" src="//www.youtube.com/embed/gYhi3pAiQY4"></iframe>
            </div>
   </div>
</div>
like image 273
Abu Talha Danish Avatar asked Aug 05 '14 15:08

Abu Talha Danish


People also ask

Why is my bootstrap responsive app not working?

It entirely depends on the bootstrap version you are working with. Bootstrap framework is under continuous improvements, and from time to time changes are made between different versions, which may affect how things work. For instance, in this case, .img-responsive works perfectly well only on bootstrap 3 or earlier versions.

How do I embed a video in a bootstrap iframe?

Below are snippets of responsive embed HTML structure for Bootstrap to wrap around iframe tags such as video embeds from YouTube or Vimeo. To use them, copy and paste the HTML into your site. The included snippet is for 16:9 aspect ratios. Consult the Bootstrap documentation for more aspect ratios and examples.

What is the difference between Bootstrap and responsive images?

Same as responsive web design, and as part of it, responsive images work well on devices with widely differing screen sizes and resolutions. Responsive images readjust their width and height to fit well in the device screen. Bootstrap, being a mobile-first CSS framework for responsive web design provides a way of making images responsive.

How do I use the aspect ratios in Bootstrap?

To use them, copy and paste the HTML into your site. The included snippet is for 16:9 aspect ratios. Consult the Bootstrap documentation for more aspect ratios and examples.


Video Answer


2 Answers

As Rob said in a comment:

Pretty sure embed-responsive wasn't added until 3.2. Try updating.

like image 161
Léo Lam Avatar answered Oct 18 '22 01:10

Léo Lam


If you're unable to update, for one reason or another, you can add the styles yourself. It's fairly straight forward. Here's the SASS:

// Embeds responsive
//
// Credit: Nicolas Gallagher and SUIT CSS.

.embed-responsive {
  position: relative;
  display: block;
  height: 0;
  padding: 0;
  overflow: hidden;

  .embed-responsive-item,
  iframe,
  embed,
  object,
  video {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
    border: 0;
  }
}

// Modifier class for 16:9 aspect ratio
.embed-responsive-16by9 {
  padding-bottom: 56.25%;
}

// Modifier class for 4:3 aspect ratio
.embed-responsive-4by3 {
  padding-bottom: 75%;
}
like image 25
Brian H Avatar answered Oct 18 '22 01:10

Brian H