【问题标题】:How to add an image to my css body background?如何将图像添加到我的 CSS 正文背景?
【发布时间】:2018-10-16 19:36:38
【问题描述】:

This 是我的图像所在的位置。

我已经尝试了图片上显示的几个选项,我的 html 上有我的 css(培训目的)C:\Users\developer\Desktop\HTML Folder2

【问题讨论】:

标签: html image css background


【解决方案1】:

以下内容取自https://css-tricks.com

感谢 CSS3 中的 background-size 属性,我们可以纯粹通过 CSS 来做到这一点。我们将使用 html 元素(比 body 更好,因为它总是至少是浏览器窗口的高度)。我们在其上设置了一个固定且居中的背景,然后使用设置为 cover 关键字的 background-size 调整其大小。

html { 
  background: url(http://enjoycss.com/webshots/hB_1.png) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

https://css-tricks.com/perfect-full-page-background-image/

【讨论】:

    【解决方案2】:
    body {
        background: url(HTML Folder2/image.jpg)no-repeat;
        background-size: cover;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-15
      • 2016-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多