Videos do not take up the full width of containers on WordPress by default. To make it simple for users just use JQuery.

The interest is to add a parent div block to apply the responsive principle to the iframe.

Add library Jquery 1.5.2

Add script on header.php

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

Add css

.parent-frame{
position: relative; padding-bottom: 56.25%; padding-top: 25px; height: 0;
}
iframe{
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}

Add script

This code detects all iframes in order to add the div with the parent-frame class.

<script>
$(function ()
{
$('iframe').wrap('<div class="parent-frame"></div>');
});
</script>
<?php endif; ?>

And it’s over!

5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Commentaires
Inline Feedbacks
View all comments