Smooth transition in javascript!! | Sololearn: Learn to code for FREE!
Nowy kurs! Każdy programista powinien nauczyć się Generative AI!
Wypróbuj darmową lekcję
+ 1

Smooth transition in javascript!!

Hello guys. Are there a way to make display = ‘none’; for <div> with smooth transition without any library like jQuery or react or used timeout or opacity = 0. ????

24th Jan 2023, 7:46 PM
Saif
Saif - avatar
3 odpowiedzi
+ 2
Display none can't have this effect but you can use opacity as Mirielle said and when opacity is 0 set display to none, so you don't have blank area at screen. If I am not wrong css animation can do this no need for js.
24th Jan 2023, 9:31 PM
PanicS
PanicS - avatar
+ 3
From the formal definition for display in its mdn article: "Animation type: not animatable" So with just css either transition or animation i believe you cant.
24th Jan 2023, 8:56 PM
arturop-404
arturop-404 - avatar
25th Jan 2023, 3:06 AM
Saif
Saif - avatar