Note that there are some explanatory texts on larger screens.

plurals
  1. POBackground-size: cover with Jquery
    primarykey
    data
    text
    <p>I am developing a Joomla website with a 100% width, wich also is responsive.</p> <p>At the same time I'm using a slider (just fadeing effects) for show more than one image, but here comes the problem. The first image (comes from the CSS background), can be displaied perfectly on mobile, but the other ones (wich came from Jquery) does not.</p> <p><strong>JS</strong></p> <pre><code> $(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 &lt; 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); } }); </code></pre> <p><strong>CSS Style</strong></p> <pre><code>#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; } </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;section id="gk-header"&gt; &lt;div class="container-fluid"&gt; &lt;jdoc:include type="modules" name="header" style="none" /&gt; &lt;/div&gt; &lt;/section&gt; </code></pre> <p><strong>CLUE</strong></p> <p>I've tried to use this code, but does not work either.</p> <pre><code> $(this).css('background-size','cover','url(' + preloadArr[currImg++%preloadArr.length].src +') '); </code></pre> <p>Thank you all</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload