图像上的Html宽度100%没有在页面上传播

时间:2015-03-14 06:37:30

标签: html css html5 css3

我有一张背景图片:

    <div style="background-image: url(images/Home/diamond.png); height: 2600px; width: 100%; border: 1px solid black;"></div>

在页面上,图像覆盖所有中心和右侧,但不包括左侧。当我尝试宽度100%时,它没有像我的其他div那样在页面上传播。如果这有帮助,则此div元素是section元素的子元素和许多其他多个div元素的父元素。

3 个答案:

答案 0 :(得分:3)

试试这个:

html { 
      background: url(images/Home/diamond.png) no-repeat center fixed; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }

答案 1 :(得分:0)

你可以试试这个:

div
{
    background: url("images/Home/diamond.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

希望这有帮助!

答案 2 :(得分:0)

尝试使用width:100vw;这可能对您有用。