I've made up a responsive menu wherein the list-item elements after the 4th get display:none; opacity:0
on mobile. The 4th element is another list item that's an icon. When you hover over the icon the hidden menu items appear as a block list below using
li:nth-child(4):hover ~ li {
display:block;
opacity:1;
}
No matter where I stick transition: all 0.5s ease
in my CSS I cannot get a transition going. Am I trying to do something that just won't work because I'm acting on a sibling selector, or am I doing something wrong?
See fiddle: https://jsfiddle.net/nicoleamurray/zap1L8hq/ which displays the mobile version.
UPDATE: Got it working really nicely with height
!
`.mainmenu{
float: right;
text-align: right;
}
.mainmenu li{
display:inline-block;
}
.mainmenu li:nth-child(4):hover ~ li{
opacity:1;
transition-delay: 0s;
height: 20px;
}
.mainmenu li:nth-child(n+5){
opacity:0;
overflow: hidden;
height: 0;
display: block;
transition: all 0.5s 1s;
}`