背景颜色不总是出现 [英] background color doesn't always show up
本文介绍了背景颜色不总是出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为我的网页设置了以下css。当页面加载背景颜色并不总是生效。我必须刷新我的页面一两次之前的颜色的作品。任何人知道为什么?背景图像不像整个页面一样高,它是一个渐变。因此,我使用渐变的底部像素颜色,并将其用作页面bg颜色。
I have the following css set up for my page. When the page loads the background color doesn't always take effect. I have to refresh my page once or twice before the color works. Anyone know why? The background-image isn't as tall as the entire page and it's a gradient. So I'm taking the bottom pixel color of the gradient and using that as the page bg color.
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
color: #000000;
margin: 0px;
padding: 0px;
background-color: #001833;
background-image: url(images/page_bg.jpg);
background-repeat: repeat-x;
background-position: left top;
}
推荐答案
Try:
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
color: #000;
margin: 0;
padding: 0;
background: #001833 url(images/page_bg.jpg) repeat-x top;
}
(如果重复则不需要指定'left'。
(You don't need to specify 'left' if its repeating.)
此外,如果您使用CSS重置(或未重置),请确保您的身体使用100%的高度:
Also, if you're using CSS reset (or not), make sure your body uses 100% height:
html, body {height: 100%;}
这篇关于背景颜色不总是出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文