2009-09-29 54 views
0

我有一个问题: 有3个divs。其中2个应该有他们的背景图像,他们的位置是在用户区域的两侧。 (一个在右边,一个在左边)。第三个div应该超过它们和全角。 我怎样才能做到这一点与CSS?html-divs position to relative

回答

0

使这两个div或第三个div绝对定位。给第三个div分配一个高于其他两个的z-index。

(好吧,就说说CSS可以去没有先例)


<style> 
    div.holder-for-left-and-right 
    { 
    width: 100%; 
    overflow: hidden; 
    position: relative; 
    } 

    div.left 
    { 
    float: left; 
    width: 100px; 
    height: 50px; 
    background: url(...) no-repeat; 
    z-index: 1; 
    } 

    div.right 
    { 
    float: right; 
    width: 100px; 
    height: 50px; 
    background: url(...) no-repeat; 
    z-index: 1; 
    } 

    div.on-top-of-them 
    { 
    position: absolute; 
    top: 0; 
    width: 100%; 
    height: 50px; 
    z-index: 2; 
    } 
    </style> 

<div class="holder-for-left-and-right"> 
    <div class="left">I am leftM</div> 

    <div class="right">I am right</div> 

    <div class="on-top-of-them">I am over them</div> 
</div> 
+0

你能告诉我一个小例子,好吗? – Ockonal 2009-09-29 15:10:52