Last active
August 29, 2015 14:06
-
-
Save laurentperroteau/a6ca0a9fa6da2066f16e to your computer and use it in GitHub Desktop.
Center backgroud with JavaScript (need jQuery)
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
centerBackground: function () { | |
if( !mobile ) | |
{ | |
var $back = $('#back-img img'); | |
var backSize = tablet ? 750 : 1490; | |
if( backSize >= Master.data.w ) | |
{ | |
var decalage = ( Master.data.w - backSize) / 2; | |
$back.css('marginLeft', decalage); | |
} | |
else { | |
$back.css('marginLeft', 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment