c# - 如何将元素移动到 div 中的左侧?

标签 c# css asp.net

我在一个 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/

相关文章:

html - 加载数据后如何将表头与表体对齐

c# - 异常信息是 'Could not load file or assembly ' MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'?

c# - 写入值数据分割

c# - C# 中类初始值设定项之间的区别?

jquery - 修复了 lightSlider 中的背景

html - CSS 选择器 : first/last-of-type and has another class

c# - Azure Web 角色抛出 web.config 中无法识别的元素 'autoDiscover'

css - 在 asp.net webforms 中设置 div 的背景或背景图像

c# - 有什么备受瞩目的开源金融项目吗?

java - 我是否应该从我的服务中抛出可重试的异常