The problem
I’m facing a problem when shifting the child element to the top of all content. I did a Sandbox to show what I’m trying to do (it’s just a simulation):
https://codesandbox.io/s/tooltip-overflow-9yx29s?file=/mystyle.css:104-124
- I need to keep the
overflow: hidden
property in the container. - The Tooltip must be set inside the container
div
div {
outline: 1px solid black;
}
.container {
position: relative;
height: 50px;
width: 500px;
overflow: hidden;
background-color: pink;
display: grid;
align-items: center;
}
.tooltip {
z-index: 9999;
top:0;
background-color: lightcoral;
position: absolute;
height: 200px;
}
<div class="container">
<div class="tooltip">fancy Tooltip content</div>
</div>
What I’m expecting:
with
overflow: hidden;
in container
I appreciate any support
2
Answers
After trying a solution. The best option if you don't have a way to work around with parents with
relative
is usingabsolute
withfixed
: https://github.com/w3c/csswg-drafts/issues/4092#issuecomment-595247838Code
With this, you can add multiple tooltips without depending on a parent with no current position relation.
there is one way.
add parent div for ".container" and remove "position: relative" from ".container"
and add it to ".grand-parent" and you have to control the height of the tooltip.