1

この 2 つの div を横に並べるのではなくオーバーラップさせる方法を教えてください。

hc_menu & #hc_show_hide

jsfiddle であり、これはコードです: css :

   .chart_scroll{  height: 100%;}
    #hc_hover{height:100%;width: 25%; float: right;}
    #hc_menu{height:400px ;background-color: Black;opacity:0.4;margin:50px 0px 50px 20px;width:125px ; float:right;}
    #hc_show_hide{height:500px ; width: 15% ;float:right ; background:red;}

html :

 <div class="chart_scroll" runat="server" id="pnlCharts">
              <div id="hc_hover" >
              <div id="hc_show_hide"></div>
                <div id="hc_menu">
                    
                </div>
              </div>
           </div>
4

3 に答える 3

2

オーバーラップを意味する場合は、上にあるものを決定するために設定position:absoluteおよび調整する必要があります。z-index

コードにいくつかの変更があるため、更新された CSS と新しいフィドルを次に示します。

 .chart_scroll{  height: 100%;} 
#hc_hover{height:100%;width: 25%; float: right; position:relative; /* Keeps the children inside of its boundry */}
        #hc_menu{height:400px ;background-color: Black;opacity:0.4;margin:50px 0px 50px 20px;width:125px ; float:right; position:absolute;  right:0; /* lets it occupy the same space, aligned to the right */  z-index:50 /* puts this one on top */ }
        #hc_show_hide{height:500px ; width: 15% ;float:right ; background:red;  position:absolute; right:0; /* lets it occupy the same space, aligned to the right */ }
于 2012-05-31T18:42:07.520 に答える
0
.chart_scroll{ width: 100%;}
#hc_menu, #hc_show_hide{width: 100px; height: 100px; float: right;  }
#hc_menu{background: blue; z-index: 1; position: relative; left: 10px; top: 10px;}
#hc_show_hide{background:red;}


<div class="chart_scroll" runat="server" id="pnlCharts">
    <div id="hc_hover" >
            <div id="hc_show_hide"></div>
            <div id="hc_menu"></div>
    </div>
</div>

上記のコードでは、青は常に赤でフレンドゾーン化されます。lol @ mattytomo

于 2012-05-31T18:51:03.377 に答える
0

を使用してそれらをオーバーラップさせることができますposition: absolute;

于 2012-05-31T18:43:23.957 に答える