为什么我的背景重复?

时间:2018-05-15 21:12:55

标签: css background-image fixed background-attachment

我正在学习如何建立一个网站,但由于背景原因我遇到了一些麻烦。

当我向div容器添加内容时,背景重复。为什么会这样,我该如何解决?

.body {
    background: url("imgs/background.jpeg")no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
.main{
   background-color:rgba(255,255,255,0.9) ;
margin:25px;

}

.container{

   width:63%;
    height:auto;
    background-color:rgba(255,255,255,0.9);
    float:left;
 box-shadow: 1px 1px 1px #000, 
               3px 3px 5px grey; 
    font-family: 'Orbitron', sans-serif;
    text-shadow: 1px 1px 1px #000, 
               3px 3px 5px grey; 
    margin-bottom: 30px;

}

2 个答案:

答案 0 :(得分:0)

添加背景重复:无重复;在身上

有关背景图片的更多信息,请阅读链接https://www.w3schools.com/cssref/pr_background-image.asp

答案 1 :(得分:0)

您正在使用background-image属性的简写语法,这是错误的。您需要background属性:

.body {
    background : url("imgs/background.jpeg") no-repeat center center fixed;
}
相关问题