Created
May 7, 2013 18:20
-
-
Save tcha-tcho/5534866 to your computer and use it in GitHub Desktop.
Fix ratio when using background images.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fix_ratio(ele){ | |
var img_ratio = 1.6;//ele.width()/ele.height(); 1920/1200 | |
var window_ratio = $(window).width()/$(window).height(); | |
if(img_ratio>window_ratio){ | |
ele.css("height","100%").css("width","auto"); | |
}else{ | |
ele.css("width","100%").css("height","auto"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use with this css