Use animation and transition property to create a fade-in effect on page load using CSS.
Method 1: Using CSS animation property: A CSS animation is defined with 2 keyframes. One with the opacity set to 0, the other with the opacity set to 1. When the animation type is set to ease, the animation smoothly fades in the page. This property is applied to the body tag. Whenever the page loads, this animation would play and the page will appear to fade in. The time of the fade in can be set in the animation property.
Method 2: Using the transition property and setting the opacity to 1 when the body is loaded: In this method, the body can be set to the opacity 0 initially and the transition property is used to animate this property whenever it is changed. When the page is loaded, the opacity is set to 1 using the onload event. Due to the transition property, changing the opacity now will appear to fade in the page. The time of the fade in can be set in the transition property.
- jQuery | fadeIn() Method
- What Happens To CSS When We Load a Page?
- How to get focused a button automatically when the page load using HTML ?
- JQuery | Set focus on a form input text field on page load
- How to execute AngularJS controller function on page load ?
- How to load jQuery code after loading the page?
- How to create Glowing Star effect using HTML and CSS?
- How to Create Paradoxical Effect using CSS ?
- How to Create Liquid Filing Effect on Text using HTML and CSS ?
- How to create shock wave or explosion effect using HTML and CSS ?
- How to Create Skeleton Screen Loading Effect using CSS ?
- How to Create Loading Blur Text Animation Effect using HTML and CSS ?
- How to create Skewed Background with hover effect using HTML and CSS?
- How to create paper corner fold effect on hover by using HTML and CSS?
- Create a 3D Text Effect using HTML and CSS
- How to Create an Effect to Change Button Color using HTML and CSS ?
- How to create a bouncing bubble effect using CSS ?
- How to Create Animated Navigation Bar with Hover Effect using HTML and CSS ?
- How to Create Embossed Text Effect using CSS ?
- How to create followspot effect using HTML CSS and jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.