html - css I dont understand what turns on a transition -
i following video tutorial how make web site css. made menu mobile appears when user click on toggle. tutor, make nicer when appears, added new style .animate. works don't understand turns on transitition.
thanks frank
body {background:#eee;} .animate{ -webkit-transition: 0.3s ease-out; transition: 0.3s ease-out; } .header{background:#333;} .header_logo{color:#fff; float:left;display:block; padding:10px;} .header_menu{float:right; margin:0px; padding:0px;} .header_menu_item{display: inline-block;} .header_menu_item a{color:#fff; display:block; padding:15px;} .header_menu_item a:hover{background-color: #000000;} .header_icon-bar{display:block; float:right; padding:20px; display:none;} .header_icon-bar span{display:block;height:3px; width:30px; background:#fff; margin-bottom:5px;} /*------------------------ tablet m --------------------------*/ @media (max-width: 998px){ } /*------------------------ smartphone --------------------------*/ @media (max-width: 767px){ .header_icon-bar{display:block;} .header_menu_item{display:block;} .header_menu{width:100%; height:0px; overflow:hidden;} .is-open{height:300px; overflow:auto;} } .clearfix:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } * html .clearfix { zoom: 1; } /* ie6 */ *:first-child+html .clearfix { zoom: 1; } /* ie7 */
<!doctype html> <html> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/6.0.0/normalize.css"> <link rel="stylesheet" href="style.css"> <meta charset="utf-8"> <title>documento senza titolo</title> </head> <body> <header class="header clearfix"> <a href="" class="header_logo">logo</a> <a href="" class="header_icon-bar"> <span></span> <span></span> <span></span> </a> <ul class="header_menu animate"> <li class="header_menu_item"><a href="">item</a></li> <li class="header_menu_item"><a href="">item</a></li> <li class="header_menu_item"><a href="">item</a></li> <li class="header_menu_item"><a href="">item</a></li> </ul> </header> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('.header_icon-bar').click(function(e){ $('.header_menu').toggleclass('is-open'); e.preventdefault(); });//end toggle }); //edn ready </script> </body> </html>
the class .animate
has webkit/transition (all css propieties), when click on .header_icon-bar
adds class .is-open
....is-open
has height 300px, class animate (and transition) make div going height:0 height:300px.
if add transition(all) class, , change css prop class, animated.
ref: https://css-tricks.com/almanac/properties/t/transition/ cheers,
Comments
Post a Comment