I have a scrollable list of elements, each element of the list has a bouncing animation on click (I simplified the below example with an enlarging transition on hover).
If the parent container isn't scrollable, there are no problems since overflow-x
works as expected only when overflow-y
is set to something different than auto
or scroll
, as stated in this question.
Desired behaviour
When the animation exceeds the boundaries of the scrollable container, it should create a new stacking context and overlap the y-axis scrollbar. It should not show a horizontal scrollbar.
What I tried so far
So far I tried:
Using
position: absolute
on hover. It doesn't work because we are inside a scrollable containerApplying an intermediate div with
overflow-x: visible
. It doesn't work for the same reason
I understood that I can't solve this problem if I won't be able to create a new stacking context on the fly, when the user hovers an item of the list.
Here is an example of the problem:
.scrollable-div {
width: 250px;
height: 400px;
overflow-y: auto;
border: solid 1px gray;
}
.grow-on-hover {
width: 90%;
height: 120px;
margin: 10px auto;
background-color: royalblue;
transition: transform 0.5s ease-in-out;
}
.grow-on-hover:nth-child(odd) {
background-color: gold;
}
.grow-on-hover:hover {
transform: scaleX(1.5);
}
<div class="scrollable-div">
<div class="grow-on-hover"></div>
<div class="grow-on-hover"></div>
<div class="grow-on-hover"></div>
<div class="grow-on-hover"></div>
<div class="grow-on-hover"></div>
<div class="grow-on-hover"></div>
</div>
Thank you.
Edit:
What should happen on hover is the following effect: