I want that when I hover over a child class, it doesn’t affect the overflow of the parent. My expectation is to remove the line position: relative;
in the parent, but this doesn’t work correctly when I have many nested positions.
.parent-1 {
position: relative;
width: 200px;
height: 200px;
background-color: red;
overflow: auto;
box-sizing: border-box;
}
.child {
width: 50px;
height: 50px;
background-color: yellow;
&:hover {
position: absolute;
height: 1000px;
}
}
<div class="parent-1">
<div class="child">
</div>
</div>
2
Answers
Try the below solution
You can not achieve that without
position: relative
. It helps to recognize where your element’s absolute position is. Otherwise, your elements will use the position (0,0) by default.If you want to have the same design but with a slightly different approach. You can try below solution with another wrapper element.