The #sub
div should make an opacity transition by hovering over #item
, but it does not work. It only works when I display: none
How do I resolve this?
#item,#sub{
height: 40px;
width: 300px;
padding: 0px;
}
#item{
background-color: red;
position: absolute;
}
#sub{
display: none;
opacity: 0;
background-color: yellow;
margin-top: 40px;
position: relative;
transition: opacity 1s linear 0s;
}
#item:hover #sub, #item #sub:hover{
display: block;
opacity: 1;
transition: opacity 1s linear 0s;
}
<div id="item">
<div id="sub">
</div>
</div>