CSS Snippets

Code Snippet

Fading in a page on load can give site items like a sidebar or icon boxes that load slowly the time to finalize their size/color without the user noticing.

Plus it can give a pleasant look as the page loads.

The way we do this is with CSS animation. The following fades in the body of the page in 0.25 seconds from 0% opacity to 100% opacity.

Place it first thing in your style sheet and adjust the timing as you like.

/* hidden to give it time to load Elementor css */
body {
    animation: fadeInAnimation ease 0.25s; /* fades in over 1/4 second */
    animation-iteration-count: 1;
    animation-fill-mode: forwards;
}
@keyframes fadeInAnimation {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
/* end hidden to give it time to load sidbar css */

CSS Notes:


We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.