html - Adding transition effect to my css -
i have following
html
<div id="left_nav_wrapper"> <div class="sidebar_wrapper"> <div class="sidebar_header">header</div> <div class="sidebar_content">content</div> </div> <div class="sidebar_wrapper"> <div class="sidebar_header">header</div> <div class="sidebar_content">content</div> </div> </div> css
.sidebar_wrapper { width: 150px; } .sidebar_header { width: 150px; background-color: #f18986; } .sidebar_content { display: none; width: 150px; margin-left: -150px; background-color: #444; } .sidebar_header:hover + .sidebar_content { display: inherit; margin-left: 0px; } i want when hover on header, content shows (which have done) want add transition slides in, when
add transition: 1s; -webkit-transition: 1s; to css not anything, have added .sidebar_header , .sidebar_content , can not figure out why not use transition when appearing.
any appreciated thanks!
transitions not work on display property. have set properties height: 0 100px have done here.
.sidebar_content { height: 0; width: 150px; margin-left: -150px; background-color: #444; -moz-transition: height 0.5s ease-in; -o-transition: height 0.5s ease-in; -webkit-transition: height 0.5s ease-in; transition: height 0.5s ease-in; } .sidebar_header:hover + .sidebar_content { height: 100px; margin-left: 0px; } you cannot transition height auto. in case don't want fix height of sidebar_content
you have transition on max-height property setting high value never reaches. have consequences. have adjust transition duration remove delay when max-height transitions 0 high value.
as maximum value of max-height increases reverse transition delayed
Comments
Post a Comment