2013-04-28 57 views
0

我真的在努力工作,但我无法弄清楚如何通过CSS创建。如何通过CSS在背景上添加图片?

基本上这website here我试图添加图像去主要内容的背景之外,你可以看到下面的这张图片。它说“Lattest Lessons”(对于错字感到抱歉)或说的地方接收我们的通讯。

有人有俱乐部吗?我迷路了!

下面是一些代码:

.main-content { 
    position:relative; 
    z-index:100; 
    padding:1em 0 8.5em 0; 
    background:#fff; 
} 

.main-content p { 
    color:#555; 
} 

.site-wrap { 
    position:relative; 
    min-height:100%; 
} 

enter image description here

+0

有你看这里,它类似的想法http://webdesign.tutsplus.com/tutorials/javascript-tutorials/create-a-sticky-navigation-header-using-jquery-waypoints/ – Kivylius 2013-04-28 16:25:27

+0

你可以接受答案还是提供更多方向?谢谢。 – Gilman 2013-05-03 19:01:40

回答

0

我会建议做的是创造,看起来像这样的背景下一个div:

HTML:

<div id="backgrounddiv"> 
</div> 

所以HTML非常简单。不要在这些div中放入任何东西。现在的CSS:

CSS:

#backgrounddiv { 
length:100%; //spans length of page 
width:100%; //spans width of page 
z-index:1; //makes sure background is behind all the other objects 
background-color: #000; //black background 
position: absolute; //isn't affected or doesn't get affected by other elements 
} 
0

你可能会找什么是正确定位的元素。这可以根据您的需要进行相对或绝对定位。在任一情况下,确保父容器是定位的元素(在您的示例,它是:相对)

见本小提琴: http://jsfiddle.net/callseng/UUxqG/

与类中的段落“移动左”被容纳的内部主要内容元素,它相对定位,然后向左推25px。

position:relative; 
left: -25px;