You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用CSS实现RadzenDataGrid行鼠标悬停变色效果

RadzenDataGrid 整行鼠标悬停颜色设置问题及解决方案

问题背景

需要为RadzenDataGrid设置整行鼠标悬停颜色,初期尝试多种CSS规则均未生效,仅能实现偶数行单个单元格的悬停变色,最终发现开启AllowAlternatingRows="true"是导致问题的核心原因。

无效尝试记录

  1. 直接定位.rz-data-row:hover设置背景色,无效果:
.rz-data-row:hover 
{
background-color: #767676 !important;
}
  1. 修改单元格悬停选择器为行选择器,无效:
.rz-grid-table-striped tbody tr:not(.rz-expanded-row-content):nth-child(even) > tr:hover{
background-color: orange !important;
}
  1. 使用错误类名.rz-grid-table-stripped(正确拼写为striped)设置交替行表格的悬停样式,无效果:
rz-data-grid .rz-grid-table-stripped tbody tr:hover {
  background-color: orange !important;
  color: white !important;
}

阶段性有效方案(无交替行场景)

在未开启交替行的RadzenDataGrid中,以下CSS可实现整行悬停效果:

.rz-data-grid .rz-grid-table tbody tr:hover {
  background-color: orange !important;
  color: white !important;
}

最终解决方案(开启AlternatingRows场景)

若仅需奇数行(无默认底色的行)在鼠标悬停时高亮,使用以下CSS规则:

.rz-grid-table-striped tbody > tr:nth-child(odd):hover > td {
    background-color: yellow !important; /* 可替换为自定义悬停颜色 */
}

内容的提问来源于stack exchange,提问作者ExecChef

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 13:42:43