Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You might want to do something like this <a href="http://jsfiddle.net/pZBMh/" rel="nofollow">jsfiddle</a></p> <h2>markup</h2> <pre><code>&lt;div id="sub-category"&gt; &lt;div id="sub-category1" class="item"&gt;Item 1&lt;/div&gt; &lt;div id="sub-category2" class="item"&gt;Item 2&lt;/div&gt; &lt;div id="sub-category3" class="item"&gt;Item 3&lt;/div&gt; &lt;/div&gt; </code></pre> <h2>css</h2> <pre><code> #sub-category{ border: 0 solid black; height: 295px; margin: 5px 300px; overflow: hidden; position: relative; width: 675px; } .item{ position: absolute; left:0; top: 0; width: 223px; height: 293px; border: solid 1px black; background: #046380; font: 44px/262px georgia; text-align: center; font-style: italic } #sub-category1{ background-color: grey; } #sub-category2{ background-color: #ffc; left: 225px; } #sub-category3{ left: 450px; background-color: lightgreen; } </code></pre> <h2>and the javascript</h2> <pre><code> function SlideDivSection() { var items = ['sub-category1', 'sub-category2', 'sub-category3']; var container = $('#sub-category') var item_width = 225; window.setInterval(function () { var first = $('.item:first', container); var faux_id = first.attr('id') + 'faux'; var faux_elem = $($('&lt;div/&gt;').append(first.clone()).html()).attr('id', faux_id).css({ left: item_width * items.length, backgroundColor: first.css('background-color') }) container.append(faux_elem); faux_elem = $('#' + faux_id, container); $('.item', container).animate({ left: '-=' + item_width }, 500, function () { first.remove(); faux_elem.attr('id', faux_elem.attr('id').replace('faux', '')) }) }, 2000) } $(function(){ SlideDivSection(); }) </code></pre> <p>This solution removes an item from one end and inserts it again from the other end. So you end up <strong>seamlessly</strong> cycling your initial elements. This behavior could be changed to "adding a new (and distinct) element" after removing an element.</p>
    singulars
    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. VO
      singulars
      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