I am developing a Joomla website with a 100% width, which also is responsive.
At the same time I'm using a slider (just fading effects) for showing more than one image, but here comes the problem. The first image (comes from the CSS background), can be displayed perfectly on mobile, but the other ones (which comes from jQuery) do not.
JS
$(document).ready(function(){
var imgArr = new Array(
'imatgesheader/fons2.jpg',
'imatgesheader/fons3.jpg'
);
var preloadArr = new Array();
var i;
/* preload images */
for(i=0; i < imgArr.length; i++){
preloadArr[i] = new Image();
preloadArr[i].src = imgArr[i];
}
var currImg = 1;
var intID = setInterval(changeImg, 100);
/* image rotator */
function changeImg(){
$('#gk-header').animate({opacity: 0.05}, 2000, function(){
$(this).css('background','url(' + preloadArr[currImg++%preloadArr.length].src +') ');
}).animate({opacity: 1}, 1000);
}
});
CSS Style
#gk-header {
background-image: url('../images/fons.jpg') ;
background-size: cover;
-moz-background-size: cover;
background-position: center;
margin-bottom:32px;
padding:130px 0;
-webkit-box-shadow:inset 0 0 3px #ebebeb;
-moz-box-shadow:inset 0 0 3px #ebebeb;
-ms-box-shadow:inset 0 0 3px #ebebeb;
-o-box-shadow:inset 0 0 3px #ebebeb;
box-shadow:inset 0 0 3px #ebebeb;
z-index: 1;
}
HTML
<section id="gk-header">
<div class="container-fluid">
<jdoc:include type="modules" name="header" style="none" />
</div>
</section>
CLUE
I've tried to use this code, but does not work either.
$(this).css('background-size','cover','url(' + preloadArr[currImg++%preloadArr.length].src +') ');