开发者

Background-position not working when classname changed in IE7

I have an element which I am adding a class to.

the style is:

.bg{ background: url(/images/background.png) no-repe开发者_运维技巧at top center #000; }

When I add the class with javascript the background image show up, and the color show up, but the positioning does not.

This works fine in everything except IE


You have defined a vertical value (top), and one that doesn't exist (middle).

The vertical values are top, center and bottom, while the horisontal are left, center and right.

When using both, the first is the horisontal and the second is the vertical, so you got them backwards.

Use:

.bg{ background: #000 url(/images/background.png) no-repeat center top; }


You're not using the CSS background: shorthand properly - you're missing the background-repeat part. It should be something like this:

.bg {
    background: #000000 url(/images/background.png) no-repeat scroll center top;
}          /*   ^       ^                           ^           ^     ^
                color   image                       repeat attachment position */

http://www.w3schools.com/css/css_background.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜