0

I have a problem with 2 divs dividing a container in 2 width 50% width.
When hovering over one it extends to 60/40%.

The problem is: While hovering over 1 (So it is extended) then quickly hovering over the other, the z-index is clipping.

check out this fiddle for an example: https://jsfiddle.net/h9vs79as/

I need the new transition to fire after the reversing transition has ended...

HTML

<div class="container">
  <div class="one">div 1</div>
  <div class="two">div 2</div>
</div>

CSS

.container { height: 200px;  width: 500px;  position: relative; }
.container div { position: absolute; height: 200px; width: 50%; z-index: 100; transition: all .5s ease; }
.one { left: 0; background-color: #00ff00; }
.two { right: 0; background-color: #ff00ff; }
.container div:hover { width: 60%; z-index: 150;  transition: all .5s ease; }
2
  • Please just add your code to the question, as @Paulie_D pointed out, Stackoverflow isn't just to help you; it is for future reference and help everyone learn.
    – B_s
    Commented Feb 9, 2016 at 12:08
  • Added it @Paulie_D Sorry, bit pissed of by this.. Commented Feb 9, 2016 at 12:08

1 Answer 1

1

You can do this with flexbox and no positioning or z-index:

.container {
  height: 200px;
  width: 500px;
  position: relative;
  display: flex;
}
.container div {
  flex: 1 1 50%;
  transition: all .5s ease;
}
.one {
  background-color: #00ff00;
}
.two {
  background-color: #ff00ff;
}

.container div:hover {
  flex: 0 0 60%;
  transition: all .5s ease;
}
<div class="container">
  <div class="one">div 1</div>
  <div class="two">div 2</div>
</div>

Not the answer you're looking for? Browse other questions tagged or ask your own question.