简体   繁体   English

CSS3背景图片不会落后于身体吗?

[英]CSS3 Background Image not going behind body?

I have a background image and when I write it in my body tag the background image works but it overlaps the text on my body. 我有一个背景图片,当我将其写在我的身体标签中时,背景图片有效,但它与我身上的文字重叠。 I want to position it behind the body and I tried using background-position and it wasn't working. 我想将其放置在身体后面,我尝试使用background-position ,但它不起作用。 How do I place the background image behind the body so it doesn't overlap? 如何将背景图像放置在身体后面,使其不重叠?

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 87.5%;
  width: 800px;
  background-color: #ffffff;
  border-color: #000000;
  box-shadow: #000000;
  background: url(../images/bats.gif) center;
  background-position: bottom;
  text-align: center;
  margin: 1em auto;
  border: 5px black;
  box-shadow: 3px 3px 3px 3px;
}

I tried your code and it's working (background-image is behind the text) see here . 我尝试了您的代码,它正在工作(背景图像位于文本后面), 请参见此处

OR You can add the background to your html tag. 或者,您可以将背景添加到html标记中。

DEMO 演示

html
{  
 background: url("paste your image url here");
}

Addition: If you want the background-image cover your full screen (browser), you can use background-size: cover; 另外:如果希望背景图像覆盖全屏(浏览器),则可以使用background-size:cover;。

Good Luck!! 祝好运!! (Sorry if this not meets your requirement). (很抱歉,如果这不符合您的要求)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM