P粉7014918972023-08-24 10:06:54
You need to hide the element in some other way for this to work properly.
I achieved this effect by positioning both If you switch the To resolve this issue, always allow the element to be There may be more solutions, but if you switch the element to But this doesn't work. In my experience, I've found that this doesn't do anything. So you always need to preserve the element P粉0717437322023-08-24 00:00:44 You can connect two or more transitions, and opacity: 0
.
display
attribute from none
to block
, the transition will not occur on other elements. 强>display: block
, but hide the element by adjusting any of the following:
height
to 0
. opacity
to 0
. overflow:hidden
element. display: none
, the conversion cannot be performed. For example, you could try something like this: div {
display: none;
transition: opacity 1s ease-out;
opacity: 0;
}
div.active {
opacity: 1;
display: block;
}
display: block
- but you can get around it by doing: div {
transition: opacity 1s ease-out;
opacity: 0;
height: 0;
overflow: hidden;
}
div.active {
opacity: 1;
height: auto;
}
visibility
will come in handy this time. div {
border: 1px solid #eee;
}
div > ul {
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.5s linear;
}
div:hover > ul {
visibility: visible;
opacity: 1;
}
<div>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>