【问题标题】:asp.net gridview cellpadding doesn't work when the gridview is placed within a html-table当 gridview 放置在 html 表中时,asp.net gridview cellpadding 不起作用
【发布时间】:2016-12-24 01:51:25
【问题描述】:

由于一些演示问题,我在普通的 html-table 中放置了一个 gridview。但是随后 cellpadding 属性不起作用。 一旦 gridview 被带到表格之外,cellpadding 就会正常工作。所以我猜这与浏览器中gridview的最终渲染有关。

有人知道这是否可能吗?有没有在表格中包含网格视图的解决方法?

【问题讨论】:

    标签: asp.net gridview cellpadding


    【解决方案1】:

    GridView(在 HTML 中也是一个表格)可能从父级继承 cellpadding。

    在这个 sn-p 中它继承了 3 的填充,而 GridView CellPadding 是 0。

    <style>
        .parentTable td {
            padding: 3px;
        }
    </style>
    
    <table class="parentTable">
        <tr>
            <td>
                <asp:GridView ID="GridView1" runat="server" CellPadding="0"></asp:GridView>
            </td>
        </tr>
    </table>
    

    所以如果你要添加这段 CSS,GridView 应该在这个例子中正确显示。

    .parentTable table td {
        padding: 0px;
    }
    

    当然有更多的可能性来解决这个问题,具体取决于您的模板、样式表、引导程序等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-11
      • 2011-06-15
      • 1970-01-01
      相关资源
      最近更新 更多