Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to slide toggle a pseudo element?

As you can see in this jsfiddle, when you click the menu button, the little triangle that points to the button is only shown after the animation has finished. I'd like the animation to start with the pseudo element and only then proceed to the drop-menu element. How can I accomplish this?

A solution doesn't necessarily have to use javascript, CSS3 will be most welcome, I'm not worried about compatibility issues.

like image 460
Ashitaka Avatar asked Mar 26 '26 06:03

Ashitaka


1 Answers

You can try this - DEMO

.drop-menu {
    display: none;
    position: relative;
    height: 60px;
    top: -20px;
}

.drop-menu ul::before {
    content: '';
    width: 0;
    height: 0;
    position: absolute;
    top: -30px;
    left: 30px;
    border-width: 15px;
    border-color: transparent transparent red transparent;
    border-style: solid;
}

.drop-menu ul {
    background-color: red;
    position: relative;
    top: 20px;
    z-index: 999;
}
like image 59
Zoltan Toth Avatar answered Mar 28 '26 19:03

Zoltan Toth