And #myDiv should have position: relative
On Sun, Feb 22, 2009 at 12:15 PM, Thomas Jaggi <thomas.ja...@gmail.com> wrote: > > They should have "position:absolute" instead if "position:relative". > > Relative means relative to the "normal" position. In this case you > would have to set negative values for top/left to achieve an > overlapping. > > > > > Petar schrieb: >> I'm trying to create and place several <img> elements inside an empty >> <div>. Images should have specific coordinates inside a div and should >> be overlapping. I tried this: >> >> $('<img src="pic1.gif" alt="" />').appendTo("#myDiv").css( { position: >> 'relative', left: '10px', top: '10px' } ); >> $('<img src="pic2.gif" alt="" />').appendTo("#myDiv").css( { position: >> 'relative', left: '30px', top: '30px' } ); >> $('<img src="pic3.gif" alt="" />').appendTo("#myDiv").css( { position: >> 'relative', left: '50px', top: '50px' } ); >> >> but images are detached horizontally, although they should overlap. >> Vertical positions are OK. >> Is there a "right way" to accomplish this? >> >> Petar