我在一个 div 中有一个标签、复选框列表和一个数据 GridView 。我使用内联 css 向左移动元素。但它并不像我预期的那样工作。我怎样才能移动它们?我想要连续的所有三个元素。下面我添加了我的 aspx 代码。
<div id="div2" style="width:100%; height:auto; margin-top:30px">
<div id="div21" style="width: 50%; height:auto">
<div id="div211" style=" width:15%; height:auto">
<asp:Label ID="lblKPI" Text="KPI :" runat="server" style="margin-top:10px; margin-left:20px">
</asp:Label>
</div>
<div id="div212" style=" width:60%; height:auto; float:left">
<asp:CheckBoxList ID="chklstKPI" style="width:auto; height:auto" runat="server">
</asp:CheckBoxList>
</div>
</div>
<asp:GridView ID="GridView1" runat="server" style="float:left">
</asp:GridView>
</div>
最佳答案
您需要将 gridview
包装在 div
中并将 float:left
设置为该 div。内部 div 也需要有 float:left
。
试试下面的 html
<div id="div2" style="width:100%; height:auto; margin-top:30px">
<div id="div21" style="width: 50%; height:auto;float:left">
<div id="div211" style=" width:15%; height:auto;float:left">
<asp:Label ID="lblKPI" Text="KPI :" runat="server" style="margin-top:10px; margin-left:20px">
</asp:Label>
</div>
<div id="div212" style=" width:60%; height:auto; float:left">
<asp:CheckBoxList ID="chklstKPI" style="width:auto; height:auto" runat="server">
</asp:CheckBoxList>
</div>
</div>
<div style="float:left;width:45%">
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField HeaderText="SomeText">
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
关于c# - 如何将元素移动到 div 中的左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39114433/