身体背景位置:中心不起作用 i.探险家
我正在制作一个网站,但我在背景位置属性方面遇到问题。这是我的 css 代码:
body
{
background-color: Black;
background-image: url(images/background_ui.png);
background-repeat: no-repeat;
background-position: top,center;
background-attachment: scroll;
}
正如你所看到的,它位于顶部、中心。在 chrome 中没问题,但在 ie 8 中背景不会水平居中。顺便问一下,你知道有哪些标签可以编写浏览器指定的CSS代码吗? 谢谢。
I am making a web site and I have trouble with background-position property. Here is my css code:
body
{
background-color: Black;
background-image: url(images/background_ui.png);
background-repeat: no-repeat;
background-position: top,center;
background-attachment: scroll;
}
As you can see it is top, center. It's ok in chrome but in ie 8 the background doesnt go center horizontally. By the way, do you know any tags to write browser specified css code?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为逗号是正确的..,它应该是:
背景位置:顶部中心
。一般来说,像background-position
或background
这样的 CSS 复合规则的值不以逗号分隔。相反,它们被一个或多个空格分隔开。例如,上面的 CSS 可以变成这样:I don't think that comma is correct.., it should be:
background position: top center
. Generally speaking, CSS compound rules likebackground-position
orbackground
do not have their values separated with commas. Instead, they get separated with one or more spaces. Your CSS from above, for instance can become like this:您的语法可能不正确。
位置应该是顶部或中间。它在 chrome 上运行而不是在 IE 上运行的事实是因为默认情况下 chromese 似乎将其居中。
我认为这可能对您有帮助:
编辑:Ioannis Karadimas 也是对的。失去逗号会给你想要的效果。尽管我仍然使用 xy 放置来避免跨浏览器出现意外。
Your syntax might not be right.
The position should be either top or center. The fact it works on chrome and not in IE is because by default chromse seems to center it.
I think this might help you:
EDIT: Ioannis Karadimas is also right. Losing the comma is going to give you your desired effect. Though i'd still use the xy placement to avoid having cross browser surprises.