将容器 div 置于另一个之上(引导程序)

Tim*_*son 4 css twitter-bootstrap

Okej,所以我试图在引导程序中将一个 div 容器置于另一个之上。

这是html代码:

<div class="container-fluid">

</div>
<div class="container">

</div>
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止得到的css:

.container-fluid{
    height: 400px;
    background: black; 
    z-index: -10;
}

.container{
    height: 800px;
    background-color: blue;
    z-index: 20;
}
Run Code Online (Sandbox Code Playgroud)

所以我想要的是 .container 位于 .container-fluid 之上。有没有一种简单的方法可以做到这一点,或者有人知道更好的方法吗?容器流体假设包含一个图像,它将成为未来的页面标题,而容器将成为站点内容。我想要容器在容器流体上的原因是,我在开头写的文本将显示在标题上,并随着屏幕尺寸变小而保持良好的位置。

谢谢!

Alv*_*dez 5

用:

position:absolute;
top:0;
Run Code Online (Sandbox Code Playgroud)

为您的容器并将两个 div 包装到另一个带有 position:relative 的 div 中。(或添加位置:相对于任何父 div 的份额)

像这样:http : //jsfiddle.net/0p8s1omp/