我能够修改gridview的行颜色,但我认为有一个默认属性来处理交替行的颜色,因为我在我的风格上指示的是红色的,但是当它显示为偶数行是红色的,而交替行是白色的。白色的行应该是绿色的。我认为这是yii为了某些可读性目的而作出的。在gridview行禁用交替的背景颜色yii2
奇怪的是,字体颜色是基于我提供的类。
<style>
.stateCritical:nth-child(even) {
color: black;
background-color: red;
}
.stateCritical:nth-child(odd) {
color: blue;
background-color: green;
}
.stateOk {
color: black;
background-color: #C0FFBE;
}
</style>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'rowOptions' => function($model) {
if ($model->last_hard_state == 2){
return ['class' => 'stateCritical'];
}
return ['class' => 'stateOk'];
},
.
.
.
.
.
?>
如何覆盖默认背景颜色?
不错!我想接受这个答案,但如果你编辑你的答案并且添加关于'!important'的解释,那你会很友善。 :) – Gibs
我添加了解释。 –
非常好解释!谢谢! – Gibs