Transition Problem and Solution in CSS
When you apply a transition
property to the labels in CSS
and refresh the page, these properties are animated while the page is loading, making it look bad on first load.
To solve this problem, one can go like this, add a class called preload
to your tag.
<body class="preload">
..
</body>
And in your css file disable transition
property of all properties under preload
.
.preload * {
-webkit-transition: none !important;
-moz-transition: none !important;
-ms-transition: none !important;
-o-transition: none !important;
}
Finally, remove this class when the page is ready, whether with jquery or vanillajs.
// jquery example
$(window).load(() => {
$("body").removeClass('preload');
});
// vanillajs example
window.addEventListener('load', (event) => {
document.body.classList.remove('preload');
});
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #Json
- #Class
- #SASS
- #Form
- #Redirect
- #API
- #Special Characters
- #Special
- #Random
- #Generating
- #
- #Text
- #Ajax
- #URL
- #Encrypting
- #React
- #Show
- #timeAgo
- #PSR-4
- #Hide
- #DDOS Protection
- #DDOS
- #cURL
- #Logic For Displaying Posts
- #Error
- #Key
- #General Error
- #1364 Field
- #Abbreviation
- #Blade
- #Version
- #QR
- #QR Code Generating
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Activate
- #Real Time
- #Socket.io
- #301
- #Custom Directives
- #Iframe Detection
- #Date
- #Characters
- #Insert
- #Autoloader
- #Composer
- #Reading
There are no comments, make the firs comment