I've encountered an issue with embedding a YouTube video on my website. Everything works fine on desktop, but when viewed on mobile devices, the iframe does not resize properly despite using media queries. How can I ensure that the iframe adjusts correctly to different screen sizes?
This is what my code currently looks like:
<div class="container-fluid text-justify bg-2" id = "video-container">
<h2 class = "text-center">Sample Text</h2>
<p>Some more sample text <br>
Another line of Sample text </p>
<div id = "video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/sIP4Gymk1nE" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/U4TUt2ukzyE" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/XS4S2O8UXqE" frameborder="0" allowfullscreen></iframe>
</div>
</div>
Additionally, here's the CSS I'm using:
#video iframe{padding: 15px;}
@media all and (max-width: 768px){
#video-container > #video > iframe{
padding: 15px;
width:100%;
height:100%;
}}
When viewed on a mobile device, the video overflows outside the div. Here's a screenshot for reference: https://i.sstatic.net/zA9XJ.png
Any suggestions on how to fix this issue would be greatly appreciated. Thank you!