Skip to content

A jQuery plugin to calculate the ration of Iframe Video embbeds and other stuff

License

Notifications You must be signed in to change notification settings

filipeversehgi/keep-ratio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

keep-ratio

A jQuery plugin to calculate the ration of Iframe Video embbeds and other stuff


How to use it

Just call it on the element you wanna keep the ratio. The default ratio is 16/9, and you can pass any ratio-string you like through the parameters.

Examples

Call it on Document Ready

<iframe width="100%" class="keepItRatio" height="315" src="https://www.youtube.com/embed/YOUTUBEID" frameborder="0" allowfullscreen></iframe>
$(document).ready(function() {
	$(".keepItRatio").keepRatio("4:3");
});

Call it on Window Resize (Too keep the ratio during resizes)

$(window).resize(function() {
	$(".keepItRatio").keepRatio();
});

Important Note

You need to pass first the ratio param in the width:height order.

ToDO

  • Calculate the ratio based on element's height rather than width

About

A jQuery plugin to calculate the ration of Iframe Video embbeds and other stuff

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published