简体   繁体   中英

Why does dropdown menu always mess my css layout?

Every time I include a dropdown menu, my css layout mess up. Can someone explain to me why and how to fix it?

Here is my code:

            <asp:Label ID="projnamelbl" runat="server" CssClass="editlabels" Text="Project                  Name"></asp:Label>
        <asp:TextBox ID="projnametxt" runat="server"></asp:TextBox><br />

        <asp:Label ID="paymentlbl" runat="server" CssClass="editlabels" Text="Payment  Type:"></asp:Label>
        <asp:DropDownList ID="paymentype" runat="server">
        <asp:ListItem Text="Cash" Value="cash"></asp:ListItem>
        <asp:ListItem Text="Intallments" Value="installments"></asp:ListItem>
        </asp:DropDownList><br />

        <asp:Label ID="projsumlbl" CssClass="editlabels" runat="server" Text="Project  Sum:"></asp:Label>
        <asp:TextBox ID="projsumtxt" runat="server"></asp:TextBox><br />

CSS:

   .editlabels {
   float:left;
   width:150px;
   margin-right:0.2em;
   padding-top:0.4em;
   padding-left:20px;
   text-align:left;
   font-weight:bold;
   }

Anything that goes after the dropdown menu goes to the right for some reason.

仅当您删除边距和填充时,东西才会自动掉落。

您需要在主容器上放置position: relative ,然后在任何子容器上使用, position: absolute

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM