【问题标题】:gridview style sheet not implemented using RowStyle未使用 RowStyle 实现的 gridview 样式表
【发布时间】:2013-11-04 04:21:46
【问题描述】:

我在 gridview 上的 asp.net 页面中使用 bootstrap css,如下所示:

<asp:GridView SkinID="VacanciesGridView" Runat="server" AllowSorting="True" AutoGenerateColumns="False" 
    BorderWidth="0" GridLines="None" CssClass="table table-condensed table-striped table-bordered table-hover gridview" >
     <RowStyle CssClass="gridRow1" />      
    <AlternatingRowStyle CssClass="gridRow2" />
</asp:GridView>

我正在尝试将自定义类应用于行样式和交替行样式。 CSS类是这样的:

.gridview .gridRow1
{
    background-color: #f4f5f8;
}

.gridview .gridRow2
{
    background-color: #FFFFFF;
}

我注意到 gridviewrow2 已应用但 gridviewrow1 cssclass 未应用。我使用 firebug 进行了检查,发现正在使用 bootstrap.css 中的 css 类:

.table-striped tbody > tr:nth-child(2n+1) > td, .table-striped tbody > tr:nth-child(2n+1) > th
{

}

如何覆盖这个 css 类。我还需要使用 gridview_rowcreated 更改 mouseover 和 mouseout 的颜色,因此我希望能够覆盖上面的 css 类,以便显示 gridRow1 样式。

【问题讨论】:

    标签: jquery asp.net css twitter-bootstrap gridview


    【解决方案1】:

    您究竟想从中获得什么?

    您正在使用自己的rowstyle css,同时您正在尝试使用引导类,如 table-hover 和 table-striped。请停止使用rowstylealternating row style css. 您可以使用css stylesheet 覆盖引导类。

    请仅使用其中一个选项,要么选择提供备用行条带化的“table-striped”引导 CSS 类,要么选择 alternating row style CSS, 当您同时应用两者时,引导程序将覆盖您的CSS.

    另外,我注意到,您正在以一种不寻常的方式使用 CSS。你应该用过这种方式。

    .gridview1{} 
    

    干杯!!!

    【讨论】:

    • 我从 gridview 中删除了 table-striped 和 table-hover,现在我的样式被应用于除第一行之外的所有行。我不知道为什么悬停和行样式不应用于 gridview 的第一行。我在 Firebug 中看到第一行没有应用 gridrow1。你能告诉我为什么我应该使用 .gridview1 而不是 .gridview 吗?
    • 如果您希望获得标题的样式,也可以将它用于标题样式
    • 就我个人而言,我宁愿继续使用引导类表悬停和表条带,而不是使用我自己的 CSS 类。如果需要,我会自定义引导类。
    • 它不是标题,它是标题之后的第二行,没有获取样式
    • table thead tr /thead then tr (not getting styles> next tr has styles
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-03
    • 2021-11-12
    • 2019-02-15
    • 1970-01-01
    • 2015-05-17
    • 1970-01-01
    相关资源
    最近更新 更多