Apologies for the very simple question! I am embedding a YouTube video on my WordPress site and want to make it responsive, is there a simple way I can add some code to the html – this is what I have at the moment:
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/zmRoFi5HCAc?rel=0" frameborder="0" allowfullscreen></iframe></center>
I think WordPress added new theme support for this (wp 5.x):
Reference: Developer Handbook
In your theme’s CSS or custom CSS section add this style:
This should make your iframe based video embeds, mobile responsive. Let me know if it worked or not? Also you may share your link please if it does not work.
Thank you
This CSS Tricks article explains how to do this well.
I put some explanatory comments in the following snippet for you.
I wrote a plugin called “Responsive Media”. It makes embedded media (by oEmbed) like a Youtube video responsive. All you have to do (after installing this plugin) is just inserting the Youtube video URL in your article.
https://nl.wordpress.org/plugins/responsive-media/