Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
So I got that
CSS
.imgA1 { position: inherit; top: 0px; z-index: 2;}
.imgB1 { position: absolute; top: 30px; z-index: 2;}
.imgB2 { position: absolute; top: 60px; z-index: 2;}

and the first image is in the middle,
What I need is to place the 2nd and the 3rd 30px under and over the top of the first image. Instead what I get is 30 and 60 pixels from the page's top.

How can I refer to the 1st image's place?
Posted
Comments
Ankur\m/ 18-Jul-11 1:20am    
Play with the z-index.
KUFIKU 18-Jul-11 1:37am    
I changed it to 1,2,3,4 but still doesn't work.
I try to do img2.place=img1.place+30px
m@dhu 18-Jul-11 1:58am    
use the firebug in FF browser and see why the issue is coming.
KUFIKU 18-Jul-11 2:03am    
it's not I get error,I just don't know how to do that

1 solution

Hi,
As per I understand your query, I try to solve it. Background color is represent your image.

Here is code and link as well

http://jsfiddle.net/KD2HL/[^]

html structure:
XML
<div class="img-wrapper">
    <span class="image-1">
    </span>
    <span class="image-2">
    </span>
    <span class="image-3">
    </span>
</div>


CSS

CSS
.img-wrapper{border:1px solid black;position:absolute;width:360px; height:260px}
.image-1{background:red; position:absolute; top:0px;left:0px; width:300px; height:200px}
.image-2{background:green; position:absolute; top:30px;left:30px;width:300px; height:200px}
.image-3{background:blue; position:absolute; top:60px;left:60px;width:300px; height:200px}
 
Share this answer
 
Comments
Sunasara Imdadhusen 7-May-14 3:26am    
Good and accepted code sample Ashish, I appreciate your efforts to the community. My vote 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900