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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.