Below is breaking, as I basically need that variable to appear as the second position value
if ($('body').is('#Home')) {
var navBarWrapperHeight = $('.navbarWrapper').height();
$('body#Home').css('background', 'url(/Images/Shared/Home_Page_Background.png) no-repeat 0 '+ navBarWrapperHeight +' fixed');
}
Tried without the plusses too
JQuery’s .css() invocation takes one of three parameter patterns:
.css(string,string|number)
.css(string,function)
.css(object)
so your function call will have to invoke the last one. $('body').css({'background': property, '-webkit-background-size': imageResponisveWebKit});
(or else call it twice, each time passing a single property to change.)
Why are you using a prefix for background-size. ? You’d have to go back over 10 years to find a browser that doesn’t support the current version Indeed I think the prefixed webkit version differed in some ways but I may be mis-remembering.
On another matter is it a good idea to find the height of your navbar with JS? Won’t that change if the user resizes text or resizes the layout? Sounds like this should be a job for CSS?
Also be aware that IOS does not behave well with background-attachment fixed and cover (or even just attachment-fixed). It spreads the image over the whole document and not the viewport.