Absolute positioned div does not show outside the relative positioned div
12,292
You can wrap the things you don't want to overflow in an element with a class called dont-overflow
. Set the width
of that class to the current .wrapper
width, and then remove the overflow from the parent and add it to that class:
CSS dont-overflow
class:
.dont-overflow
{
overflow-x: hidden;
overflow-y: scroll;
width: 200px;
height: 200px;
}
HTML:
<div class='wrapper'>
<div class='inner-wrapper'>
<div class='content-wrapper'></div>
<div class='dont-overflow'>
<div class='content-wrapper'></div>
<div class='content-wrapper'></div>
<div class='content-wrapper'></div>
</div>
</div>
</div>
Author by
Jayant Varshney
Love working on NodeJS and learning TypeScript. Solutions Expert!
Updated on June 04, 2022Comments
-
Jayant Varshney almost 2 years
Please look at the following example
I want to show my green colored div outside the
wrapper
. I cannot change the positioning of thewrapper
div asinner-wrapper
also holds some other content which may come out when we change theposition:relative
toposition:static
.How can I do this?
-
Josh Powell over 10 years-1 because the wrapper has an
overflow-x:hidden;
andoverflow-y:scroll;
. If you edit your answer I will remove -1. -
Jayant Varshney over 10 yearsThanks Alex! but.. Need overflow over wrapper.. :P
-
Alex W over 10 years@JayantVarshney Can you explain the need for overflow? What you are asking is impossible if you can't change any of your CSS or HTML