2016-02-20 25 views
-1

this first image is actual output am now getting 遇到的问题与应用CSS背景附件

the second image is my required output

这里是我申请了部分的CSS把这个背景:

#banner{ 
    background: #242a33 url(../images/sliderbg.jpg) no-repeat 50% 50%; 
    background-size: cover; 
    background-position:center; 
    background-attachment: fixed; 
} 

我使用的是相同的其他部分的CSS代码工作正常。我不知道这里有什么问题。 BG图像大小为1600px * 400px。

+0

哪个图像是期望的结果? – amflare

+0

@amflare第二个 –

回答

0

开关background-size: cover;background-size: contain;。您可能需要修改background-position并将其设置为background-position: top;才能获得理想的效果。

+0

我希望图像覆盖整个宽度,甚至放大和缩小。我试过包含它已经带来的空间或图像固定不工作 –

+0

'background-size:auto 100%;' – amflare

+0

它不工作 –

0
#Banner { 
    background-size: 100% 100%; 
    background-attachment: fixed; 
    background-position: center; 
    background: url('PathToImage'); 
    display: table; 
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 600px; 
} 
+0

嗨我试过上面的代码,但当我缩小图像幻灯片向左,但我希望它是固定全宽度BG –