簡體   English   中英

並排對齊兩個div

[英]aligning two divs side by side

我有這段HT​​ML代碼。 我喜歡wuiLeftArea和wuiMainArea始終保持並排。 現在,當縮小瀏覽器窗口時,WuiMainArea div將低於wuileftArea。 有沒有辦法強迫wuiMainArea div始終保持在正確的位置?

<div id="wuiLeftArea">
        <div id="wuiLefthandNavRoot">
            <div id="tree">
            </div>
    </div>
</div>

<DIV id=wuiMainArea sizcache="5" sizset="1">
    <DIV id=wuiMainContent sizcache="5" sizset="1">
        <DIV id=wuiInpageNav sizcache="5" sizset="1">
              <DIV id=chart class=wui-inpage-container style="float:right; width: 1200px;min-height:500px;display: block; overflow: hidden;">
              <p > this is the area to put charts. this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                        this is the area to put charts. 
                </p>
            </DIV>
        </DIV>
    </DIV>
</DIV>

除非容器上有固定的大小或顯式設置溢出,否則這種情況將始終發生。 否則,無論何時調整任何容器的尺寸,都將重新排列其子代以使其寬度方向適合其主體。

http://jsfiddle.net/XCEjf/

.wui-inpage-container {
    width: 50%;
}

通過使用相對寬度,您可以使浮動元素始終在頁面寬度中留有空間,從而防止換行。

使用基於百分比的長度。 如果左側容器占頁面寬度的25%,而主容器占頁面寬度的75%,那么無論瀏覽器多么小,您都將有1/4 3/4的分割

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM