c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
HTML

How to make youtube video responsive for website?

| | Css , Html

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: