2011-11-13 63 views
0

我有一个网页,其背景图像需要保持清晰和焦点。CSS - 用黑色填充网页的其余部分

的问题是,要实现它显然有每次有一组尺寸。

我需要在剩余的空间用黑色(其将从屏幕尺寸屏幕大小而异)填充的方法。

,看看我说的最简单的方法是,如果你去的网页:(无自我宣传的意思) http://hopeish.com

特别是如果你使用的是Chrome和Firefox - 如Safari是好的和IE不以同样的方式

任何想法我怎么能做到这一点受到影响?

+0

我不知道你想要什么,但'背景颜色:#000;'体上设置会使页面的其余部分为黑色。 – mx0

回答

2
background: url(image.jpg) #000 no-repeat; 
0

您目前有:

body { 
    background: url(image.jpg); 
    background-repeat: no-repeat; 
    /*background-attachment:fixed;*/ 
} 

添加background-color: black;有一个全黑的背景。

body { 
    background-color: black; 
    background: url(image.jpg); 
    background-repeat: no-repeat; 
    /*background-attachment:fixed;*/ 
} 

或者使用在其他答案中看到的简写背景属性变体。

http://reference.sitepoint.com/css/background

0

可以用简单的CSS实现。

body { 
    background: url('http://hopeish.com/image.jpg') no-repeat top right black; 
} 

Here's a live example

1
background:#000 url(image.jpg) bottom right no-repeat; 

这样您的图片会在右下角,其余的将被填充为黑色。

相关问题