Bootstrap 3, 4 responsive YouTube embed iframe video?

Bootstrap 3, 4 responsive YouTube embed iframe video?

Bootstrap is always changing, if you have an old code, embeding a YouTube video might not work.

But there is an easy fix, you can manually add the code resposible for embed YouTube videos in your page.

Here is the css code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<style>
.embed-responsive {
  position: relative;
  display: block;
  height: 0;
  padding: 0;
  overflow: hidden;
}
.embed-responsive .embed-responsive-item,
.embed-responsive iframe,
.embed-responsive embed,
.embed-responsive object,
.embed-responsive video {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.embed-responsive-16by9 {
  padding-bottom: 56.25%;
}
</style>

And here is the html code that can work as an example for your embeded video.

2
3
4
5
6
7
8
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/sCUt1BvAlYM"></iframe>
</div>
</div>
</div>

Add a comment: