如何在CSS中包含图像到标题(以及内容)?

如何在CSS中包含图像到标题(以及内容)?,css,Css,在上,我已经包括了一个背景(在联系页面上)。然而,当我把它放在背景中时,它并没有覆盖标题。它已经在主页上完成了,但没有在联系人页面上完成?我试着用 #siteWrapper{ background-image: url("http://static.squarespace.com/static/545d45afe4b08eea0ac65e7a/t/54612b8ae4b0ca233d43bdee/1415654282657/Website%20Background%20Trees.png")

在上,我已经包括了一个背景(在联系页面上)。然而,当我把它放在背景中时,它并没有覆盖标题。它已经在主页上完成了,但没有在联系人页面上完成?我试着用

#siteWrapper{
  background-image: url("http://static.squarespace.com/static/545d45afe4b08eea0ac65e7a/t/54612b8ae4b0ca233d43bdee/1415654282657/Website%20Background%20Trees.png");
  background-repeat: no-repeat;
  background-size: 100%;
}
因此,在这里,它将背景放进去,并将其与
背景大小为100%的屏幕相匹配但这只会覆盖内容。我试着把背景放在身体上,但是这已经把它放在了内容后面。因此,主要目标是尝试将背景和内容(如主页)一起包含到标题中谢谢

从以下位置删除标题:

body.transparent-header:not(.has-banner-image) #header {
    background-color: #100806;
    position: relative;
} //site.css line 10

尝试在#site元素上设置背景图像。

解决方案#1: 您在联系人页面的标题中使用了
position:relative
,但在主页上使用了
absolute

将此CSS用于除主页外的所有页面:

header {
    position: absolute;
    top: 0;
    left: 0;
    background: none;
}
#siteWrapper {
    padding-top: 106px; /* leave some space for header */
}
解决方案#2: 将背景图像移动到
#站点
,并删除黑色背景:

#site {
    position: relative;
    background-image: url("http://static.squarespace.com/static/545d45afe4b08eea0ac65e7a/t/54612b8ae4b0ca233d43bdee/1415654282657/Website%20Background%20Trees.png");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
}
header,
#siteWrapper {
    background: none;
}

旁注:

请小心,
Submit
按钮可能恰好出现在背景图像中有闪电区域的位置,使其无法读取:

CSS更改:

//将此#站点css更改为

    #site {
 background: url("http://static.squarespace.com/static/545d45afe4b08eea0ac65e7a/t/54612b8ae4b0ca233d43bdee/1415654282657/Website%20Background%20Trees.png") repeat scroll 0 0 / cover rgba(0, 0, 0, 0);
position: relative;
}

//删除下面的css类

.collection-545e428fe4b0f79db6910e91 #siteWrapper {
background-image: url("http://static.squarespace.com/static/545d45afe4b08eea0ac65e7a/t/54612b8ae4b0ca233d43bdee/1415654282657/Website%20Background%20Trees.png");
background-repeat: no-repeat;
background-size: 100% auto;
}

//去除背景色css在下面两部分“背景色:#100806”

网站包装{背景色:#100806;} body.transparent header:not(.has banner image)#header{背景色:#100806;}

恐怕所有这些都不起作用(以及其他解决方案)。我已经试着玩了一段时间,但没有运气。@Bitenfleax我在你的网站上成功地尝试过。啊,谢谢你的留言。当我把内容放在上面时,它会把它移到光线之外。谢谢你。那么我是不是要删除代码,然后把你的解决方案2放进去?因为当我尝试时,我没有成功?我将不得不推迟到以后,因为我要再等5个小时左右才能回来。谢谢你的评论。shmm还没有起作用。我认为这是
#站点
,因为无论我做什么都不会改变。它叫什么不同的东西,因为我看了,什么也找不到。它没有起作用?我是否只需要将
siteWrapper{background color:#100806;}
主体。透明标题:not(.has banner image)#标题{background color:#100806;}
放在您要放的代码下面两行不同的代码?
.collection-545e428fe4b0f79db6910e91 #siteWrapper {
background-image: url("http://static.squarespace.com/static/545d45afe4b08eea0ac65e7a/t/54612b8ae4b0ca233d43bdee/1415654282657/Website%20Background%20Trees.png");
background-repeat: no-repeat;
background-size: 100% auto;