css - Create a CSS3 flip-down animation for menus -
i know there plenty of examples out there i'm having trouble making work specific html.
the html cannot changed, it's wordpress generated.
i have menu sub-menu containing 2 items.
i want create css3 animation flips down children items consecutively in example: http://cssdeck.com/labs/navigation-dropdown-with-flip-effect
i've been playing around code found in pen http://codepen.io/ganesh_r/pen/tmhsj not seeing similar attempting do.
my code pretty simple:
.sub-menu{-webkit-transform-style: preserve-3d;} .has-children:hover .sub-menu li{transition: 0.5s;transform-origin: 0px 0px;transform: rotatex(-90deg);}
i figured somewhere close after i'm seeing nothing. , i've hit bit of brick wall can't work out why i'm seeing nothing using code.
any ideas how can achieve consecutive drop down? html sample:
<li class="has-children main-link"><a>top level menu item</a> <ul class="sub-menu"> <li><a>item one</a></li> <li><a>item two</a></li> </ul> </li>
and here js fiddle https://jsfiddle.net/656mxu6w/
see updated js fiddle: https://jsfiddle.net/j5su2upp/1/
in short need according sample provide hide drop down using transformations instead of display:none
, re-transform show on hover using different transition delays different elements of menu in order "flip-down" effect. difference between code , sample being since don't have separate classes each individual li
(and can't add them since can't update markup) need use nth-child
selectors in css apply different styles different li
elements.
the animation-specific styles therefore end this:
.sub-menu li { -webkit-transform-origin: 50% 0%; -o-transform-origin: 50% 0%; transform-origin: 50% 0%; -webkit-transform: perspective(350px) rotatex(-90deg); -o-transform: perspective(350px) rotatex(-90deg); transform: perspective(350px) rotatex(-90deg); position: absolute; } .sub-menu li:nth-child(1) { -webkit-transition:0.2s linear 0.2s; -o-transition:0.2s linear 0.2s; transition:0.2s linear 0.2s; } .sub-menu li:nth-child(2) { -webkit-transition: 0.2s linear 0s; -o-transition: 0.2s linear 0s; transition: 0.2s linear 0s; top: 94px; } .has-children:hover .sub-menu li { -webkit-transform: perspective(350px) rotatex(0deg); -o-transform: perspective(350px) rotatex(0deg); transform: perspective(350px) rotatex(0deg); -webkit-transition:0.2s linear 0s; -o-transition:0.2s linear 0s; transition:0.2s linear 0s; } .has-children:hover li:nth-child(2) { -webkit-transition-delay: 0.2s; -o-transition-delay: 0.2s; transition-delay: 0.2s; }
edit: absolute positioning has been used overlap content following menu instead of pushing downwards. updated js fiddle https://jsfiddle.net/j5su2upp/2/
Comments
Post a Comment