-4

I want the display:block to fade in

HTML:

<div>Fade</div>

CSS:

div{display:none;transition:2s;}
div:hover{display:block;}

Somehow it doesnt work , is there any other way to achieve this effect?

m0bi5
  • 8,900
  • 7
  • 33
  • 44

1 Answers1

1

You cannot transition the display property. Instead you should transition the opacity property.

The underlying reason for this has to do with the browsers rendering pipeline. It needs to properly layout the page before transitioning and an element with 1display: none;` has no layout (thus cannot be transitioned).

Dane O'Connor
  • 75,180
  • 37
  • 119
  • 173