Oh, there are several things in CSS that sometimes stress me!
I have a parent element responsible for listing multiple items. And within these items, when I mouse over a particular link, a dialog (or balloon) is displayed that shows some information. And this balloon is with position: absolute
, with the scenario very close to that:
.pai {
background-color: #ccc;
overflow: auto;
max-height: 300px;
}
.item {
background-color: lightblue;
height: 50px;
position: relative;
}
.item a{
padding: 10px;
display: inline-block;
text-decoration: none;
color: #049;
}
.dialogo {
display: none;
}
.item a:hover+.dialogo {
display: block;
position: absolute;
background-color: #fff;
box-shadow: 0 2px 2px #ccc;
padding: 15px;
z-index: 1000
}
<div class="pai">
<div class="item">
<a>passe o mouse aqui</a>
<div class="dialogo">Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde molestias vel ducimus, delectus recusandae veritatis asperiores reiciendis dicta a, voluptatibus quaerat quis in, sunt quas! Aspernatur dolore odit non illo!</div>
</div>
<div class="item">
<a>passe o mouse aqui</a>
<div class="dialogo">Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde molestias vel ducimus, delectus recusandae veritatis asperiores reiciendis dicta a, voluptatibus quaerat quis in, sunt quas! Aspernatur dolore odit non illo!</div>
</div>
<div class="item">
<a>passe o mouse aqui</a>
<div class="dialogo">Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde molestias vel ducimus, delectus recusandae veritatis asperiores reiciendis dicta a, voluptatibus quaerat quis in, sunt quas! Aspernatur dolore odit non illo!</div>
</div>
<div class="item">
<a>passe o mouse aqui</a>
<div class="dialogo">Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde molestias vel ducimus, delectus recusandae veritatis asperiores reiciendis dicta a, voluptatibus quaerat quis in, sunt quas! Aspernatur dolore odit non illo!</div>
</div>
</div>
Note that by hovering over .item a
, .dialogo
is cut, by overflow:scroll
or overflow: hidden
.
That is, it seems that z-index
combined with position: absolute
have some kind of conflict, because even with z-index
, part of the dialog is hidden.
Is there a way to debunk this chatisse in CSS?
Is there any way to solve it, without having to change everything I've done or changing as little as possible?
Note : I would like to resolve with CSS only, without Javascript, please.