How to window.scrollTo() with a smooth effect

2018 Update Now you can use just window.scrollTo({ top: 0, behavior: ‘smooth’ }) to get the page scrolled with a smooth effect. const btn = document.getElementById(‘elem’); btn.addEventListener(‘click’, () => window.scrollTo({ top: 400, behavior: ‘smooth’, })); #x { height: 1000px; background: lightblue; } <div id=’x’> <button id=’elem’>Click to scroll</button> </div> Older solutions You can do something … Read more

CSS3 Transition – Fade out effect

Here is another way to do the same. fadeIn effect .visible { visibility: visible; opacity: 1; transition: opacity 2s linear; } fadeOut effect .hidden { visibility: hidden; opacity: 0; transition: visibility 0s 2s, opacity 2s linear; } UPDATE 1: I found more up-to-date tutorial CSS3 Transition: fadeIn and fadeOut like effects to hide show elements … Read more

How to transition CSS display + opacity properties

Based on Michaels answer this is the actual CSS code to use .parent:hover .child { display: block; -webkit-animation: fadeInFromNone 0.5s ease-out; -moz-animation: fadeInFromNone 0.5s ease-out; -o-animation: fadeInFromNone 0.5s ease-out; animation: fadeInFromNone 0.5s ease-out; } @-webkit-keyframes fadeInFromNone { 0% { display: none; opacity: 0; } 1% { display: block; opacity: 0; } 100% { display: block; … Read more