如何在3个浮点数中堆积中心div:left divs

时间:2015-06-20 18:47:41

标签: html css center

以下3个并排的div正在工作,但我需要在中心位置下方添加更多div,尊重中间部分的宽度。但是所有3个都向左浮动,所以我无法弄明白。

<div>
        <div class="left" style="width:20%">LEFT</div>
        <div class="left" style="width:60%">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
        <div class="left" style="width:20%">RIGHT</div>
        <div style="clear: left;" />
    </div>

此外:

 .left {
        float: left;
        word-break: break-all;
    }

1 个答案:

答案 0 :(得分:-1)

如果我理解你的问题,这可能就是你要找的。我基本上创建了另一行div,然后将左div的可见性设置为隐藏。这是JSFiddle

<div>
    <div class="left" style="width:20%">LEFT</div>
    <div class="left" style="width:60%">middle
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    <div class="left" style="width:20%">RIGHT</div>
    <div style="clear: left;" />

<br />
<div class="left" style = "width:20%; visibility:hidden">LEFT</div>
<div class = "left" style="width:60%">middle
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    <div class="left" style="width:20%"></div>
</div>