I have a list of images, which I’d like to stack, one on top of each other, then offset each image by 30px top and left.
<ul>
<li><img src="#"></li>
<li><img src="#"></li>
<li><img src="#"></li>
<li><img src="#"></li>
<li><img src="#"></li>
</ul>
I found a jsFiddle of a similar effect (http://jsfiddle.net/BrAbs/1/) but require the left position to be offset and increase for each image too (0px, 30px, 60px, 90px) etc.
Using jQuery:
Fiddle
Requires
position:relativeon the elements which you’re setting theleftCSS property to.As requested, you can also use
absolutely positioning relative to anrelatively positioned ancestor if you need the stack effect without settingheighton thelis:Then the updated JS adding a
topoffset:Fiddle