1
Ah, there are a few things in CSS that sometimes stress me out!
I have a parent element responsible for listing several items. And inside these items, when I pass the mouse on a given link, a dialog (or balloon) is shown that shows some information. And this balloon is with position: absolute
, with the scenario very close to this:
.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 when passing the mouse over the .item a
, the .dialogo
appears cut, by overflow:scroll
or overflow: hidden
.
That is, it seems that the z-index
combined with position: absolute
have some kind of conflict, because even with the z-index
, part of the dialogue is hidden.
Is there any way to make this boring in CSS?
There’s some way to fix it without me having to change everything I’ve ever done or by modifying as little as possible?
Observing: I would like to solve only with CSS, no Javascript, please.
The part of
dialog
is cut due tomax-height
of the elementpai
, no?– MagicHat
@Magichat then, but considering I’m using one
z-index
larger, expected a different behavior.– Wallace Maxters
The
z-index
will do the part of it, now when you set the maximum height of 1 element, the attributes able to manipulate this behavior are height...– MagicHat
@Magichat not only that. If the element for example does not have a Width set and has
overflow: hidden
, it will hide Absolute inside it... That’s boring.... I wanted CSS to have an easier way to solve this.– Wallace Maxters
"Hide the Absolute inside him(it self?)...!!!" man became occult? What are you talking about came? What exactly is the expected behavior? kkkk[
– MagicHat
@Magichat generally, the
z-index
combined with Absolute does what? it places that element with position above the others (as if it were a layer).– Wallace Maxters
Consider adding the
;
after declaring the desired attribute. (kkkkk)– MagicHat
I don’t know if you’re cutting No...
– MagicHat
Possible duplicate of Position Absolute not activate overflow: auto
– Sam