In this tutorial how I applied responsive view for youtube video using the bootstrap. Here I used bootstrap 3.3.7 css library. I will maintain the aspect size of the youtube video for desktop, mobile or tablet views.
Piece of code for youtube video responsive:
<div class="embed-responsiveembed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/ImFG7baf0Qk"></iframe>
</div>
Responsive youtube embed bootstrap
You just replace the youtube id from the above code with yours.
HTML CODE with references for responsive view:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<h2>Fixed Embed</h2>
<div class="row">
<div class="col-md-6">
<iframe width="700" height="450" src="https://www.youtube.com/embed/ImFG7baf0Qk" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<h2>Responsive Embed</h2>
<div class="row">
<div class="col-md-6">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/ImFG7baf0Qk"></iframe>
</div>
</div>
</div>
<p>Creates a responsive video and scale it nicely to mobile view.</p>
<div class="clearfix" >
</div>
</div>
</body>
</html>
VIDEO GUIDE:
Post your comments / questions
Recent Article
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
Related Article