Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing jQuery to cycle through 4 banner images contained in 1 sprite
    text
    copied!<p>I have 4 banner images, and I want to cycle through them using a basic fade animation in an infinite loop. I found this jQuery plugin: <a href="http://jquery.malsup.com/cycle/" rel="nofollow noreferrer">http://jquery.malsup.com/cycle/</a> and have tried to do it this way:</p> <p>HTML:</p> <pre><code>&lt;div id="banner"&gt; &lt;div id="home-banner-1"&gt;&lt;/div&gt; &lt;div id="home-banner-2"&gt;&lt;/div&gt; &lt;div id="home-banner-3"&gt;&lt;/div&gt; &lt;div id="home-banner-4"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>#banner { margin: 0 auto 20px; width: 940px; } #home-banner-1 { background: url(../Images/home_banner.png) no-repeat 0 0; height: 271px; } #home-banner-2 { background: url(../Images/home_banner.png) no-repeat 0 -272px; height: 271px; } #home-banner-3 { background: url(../Images/home_banner.png) no-repeat 0 -544px; height: 271px; } #home-banner-4 { background: url(../Images/home_banner.png) no-repeat 0 -816px; height: 271px; } </code></pre> <p>JAVASCRIPT:</p> <pre><code>&lt;script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#banner').cycle('fade'); }); &lt;/script&gt; </code></pre> <p>What ends up happening is that NONE of the banners show up due to position: absolute being set on each one during the cycle. What am I missing here? Shouldn't this just work? Is there a better way to do this?</p>
 

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