【问题标题】:Html Body Background ImageHtml 正文背景图像
【发布时间】:2016-02-21 03:26:51
【问题描述】:

在body 标签中,我添加了background-image。但是图像重复了 4 次。如何解决该问题以仅显示一次?

HTML 代码:

<body background="image.png"></body>

CSS 代码:

body{
    background-image : no-repeat;
}

【问题讨论】:

  • 请在此处发布您的问题之前尝试自己找到解决方案,如果您这样做了,我猜您需要几秒钟才能找到此问题的答案!

标签: html css


【解决方案1】:

你已经习惯了

body{background:url('image.png') no-repeat};

或者这个

body{
   background-image:url('image.png'); // for your body background
   background-repeat: no-repeat;      // for your body  background repeat 
}

【讨论】:

    【解决方案2】:

    这是background-repeat 身体

    body{
       background-repeat: no-repeat;
    }
    

    【讨论】:

      【解决方案3】:

        html { 
            background: url(http://p1.pichost.me/i/64/1886374.jpg) no-repeat center center fixed; 
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
          }
      <html>
        <body>
         </body>
      </html>

      【讨论】:

        【解决方案4】:

        您可以使用 style 属性为 body 标签添加样式:

        <body style="background-image:url('image.png');background-repeat: no-repeat;">
        

        【讨论】:

          【解决方案5】:

          从正文中删除背景并应用您的 CSS,如下所示。

          body
          {
            background-image:url('image.png');
            background-repeat:no-repeat;
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-03-21
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-01-25
            • 1970-01-01
            • 2013-03-13
            • 1970-01-01
            相关资源
            最近更新 更多