Consider the following code:
<html>
<head>
<style>
body {
background-color: #CCC;
}
.con {
background-color: #FFF;
width: 80%;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="con">
[SITE CONTENT]
</div>
</body>
</html>
What I am trying to achieve is to have the content background in white color which takes 80%
of the screen width and will be in center.
Body background (10%
right and 10%
left) will be of gray color. (80%
of the center will be occupied by the content div
with white background).
It is working fine. But most of the times when the page loads, (mostly when network is slow), initially the content also will appear in gray background and then it changes to white.
What is the best way to avoid this transition effect?
I am now thinking of the following options:
a. Change color of body at the end using js
b. Initially in css, background color of body also be white and then at the end of document, override css and make it gray.
But I am sure there is a better solution. Please help.