html - CSS display none and opacity animation with keyframes not working -


I have display: none; is a very basic piece of HTML with the purpose of animating display: block with opacity changing from 0 to 1.

I am using a Chrome browser, which uses -webkit to make prefix animation as priority as possible -webkit-keyframes Transition Set Although, it is not working and simply changes display without vanishing.

I have JSFiddle.

  & lt; Html & gt; & Lt; Top & gt; & Lt; Style type = "text / css" & gt; #myDiv {display: none; Opacity: 0; Padding: 5px; Color: # 600; Background color: #cc; -Winkit-infection: 350 ms display-any infection; } # Spinach: hover & gt; #myDiv {Opacity: 1; Display area; } # Parent {background-color: # 000; Color: #fff; Width: 500px; Height: 500px; Padding: 5px; } @ -webkit-keyframe display-no-infection {0% {display: none; Opacity: 0; } 1% {display: block; Opacity: 0; } 100% {display: block; Opacity: 1; }} & Lt; / Style & gt; & Lt; Body & gt; & Lt; Div id = "parent" & gt; Hover over me ... & lt; Div id = "mydiv" & gt; Hello! & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Head & gt; & Lt; / Html & gt;  

if you are using @keyframes You -webkit-transition instead of -webkit-animation . Here is the Doctor for Animation: @keyframes .

See code snippet below:

 . Parent {background-color: # 000; Color: #fff; Width: 500px; Height: 500px; Padding: 5px; } .myDiv {display: none; Opacity: 0; Padding: 5px; Color: # 600; Background color: #ccc; }. Parent: Hover MyDiv {display: block; Opacity: 1; / * "Both" browsers ask to use the opacity at the end of the animation (best practice) * / -webkit-animation: display-none-transition 1s both; Animation: Performance - No transition is both 1s; } @ -webkit-keyframe display-no-infection {0% {opacity: 0; }} @ Keframe display-no-infection {0% {opacity: 0; }}  
  & lt; Div class = "parent" & gt; Hover over me ... & lt; Div class = "mydiv" & gt; Hello! & Lt; / Div & gt; Updated  

Updated answer

To reflect today's best practices, Instead of a transition code

 . Parent {background-color: # 000; Color: #fff; Width: 500px; Height: 500px; Padding: 5px; } .myDiv {Opacity: 0; Padding: 5px; Color: # 600; Background color: #ccc; Webkit-Infection: Opacity 1S; Transition: Opacity 1s; }. Parent: Hover. MyDiv {opacity: 1; }  
  & lt; Div class = "parent" & gt; Hover over me ... & lt; Div class = "mydiv" & gt; Hello! & Lt; / Div & gt; & Lt; / Div & gt;  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -