Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Overlay one div over another on hover

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #280258
    anikait1
    Participant

    I have this design where I have a parent container of fixed height and width. Then this parent container has three divs of equal height but different widths (specified using percentage).

    What I want to achieve is when I hover over one of the divs(in this case, the one on the left side) that it expands and overlays over the second one.

    In context of this code, I want the message div to hover/overlay over the info div, when I hover over the message div.

    https://codepen.io/anikait-makkar/pen/yGJExm

    #280259
    Paulie_D
    Member

    A minimal demo in Codepen.io would be more use that a small amount of code in a codedump.

    #280262
    anikait1
    Participant

    Posted a link to codePen

    #280263
    Paulie_D
    Member

    If you are using flexbox this is going to be tricky as an overlay will require absolute positioning.

    If so, then the message element would not take up any space in the parent which is obviously a problem.

    #280265
    JeroenR
    Participant

    Maybe you could fake it by adding the following? This way the width for both of them is changed as if the first one is on top of the second.

    .message:hover {
      width: 60%;
    }
    .message:hover + .info {
      width: 0;
    }
    
    #280342
    anikait1
    Participant

    I have tried doing this but it looks very odd with this and further I have some text in the message div and the way it all gets displayed is not pleasing.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.