Jump to content

possible to position div under a div where position is defined as absolute?


Zombay

Recommended Posts

Hi!

I'm new with CSS and this is probably very stupid question... :)

 

Is it possible to get div2 under div1 if div1 height changes (onmouseover)?

 

<div style="float:left;position:absolute;width:200px;border: 1px solid #cdcdcd;">div1</div>

<div style="float:left;width:200px;border: 1px solid #cdcdcd;">div2</div>

 

 

I have this image-gallery where you can change image onmouseover and images have different height.. so I would like everything below image-div to change position too... I quess it's not possible if div1 position is set to absolute?

yes, this is possible.

You should have a look into  the property z-index

Anything with a state other than static (absolute, relative, fixed position) can have such a z-index.

it could look like this: the onclick is javascrit, all you need to do is change the property of the z-index

div#first{
      position:relative;
      z-index: 10;
}
div#second{
     position:absolute;
     z-index: 5;
}

 

Btw carefull with naming your div's or elements btw, they may not start with a number. rather give them a logical name

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.