如何使div落后于另一个div?

问题描述 投票:21回答:6

我正在尝试将“ box-left-mini”放在下面的div前面。

<div class="box-left-mini">
   this div is infront
    <div style="background-image:url(/images/hotcampaigns/campaign-sample.png);height:100px;width:100px;">
        this div is behind
    </div>
</div>

box-left-mini的CSS为:

.box-left-mini {
    float:left;
    background-image:url(website-content/hotcampaign.png);
    width:292px;
    height:141px;
}
html css
6个回答

5
投票

您需要将z-index添加到div,顶部div为正数,下方的div为负数


3
投票

以一般方式回答问题:


0
投票

一种可能是这样,


0
投票
container can not come front to inner container. but try this below :

Css :
----------------------
.container { position:relative; }
    .div1 { width:100px; height:100px; background:#9C3; position:absolute; 
            z-index:1000; left:50px; top:50px; }
    .div2 { width:200px; height:200px; background:#900; }

HTMl : 
-----------------------
<div class="container">
    <div class="div1">
       Div1 content here .........
    </div>
    <div class="div2">
       Div2 contenet here .........
    </div>
</div>

0
投票

请确保不要隐藏溢出。如果将其设置为hidden,则将不允许您的新div(在上层元素被隐藏:hidden的父元素内)弹出或与其他div重叠。

© www.soinside.com 2019 - 2024. All rights reserved.