【问题标题】:Why is my background repeating?为什么我的背景重复?
【发布时间】:2018-05-15 21:12:54
【问题描述】:

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

当我将内容添加到 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;

}

【问题讨论】:

  • 你的 CSS 不起作用:background-image 只接受一个 URL,没有其他参数。请改用 background 短格式

标签: css background-image fixed background-attachment


【解决方案1】:

您正在使用带有background-image 属性的速记语法,这是错误的。为此,您需要 background 属性:

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

【讨论】:

    【解决方案2】:

    添加背景重复:不重复;身体上

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-02
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 1970-01-01
      • 2021-08-29
      相关资源
      最近更新 更多