使用 bootstrap 给元素添加背景色

1、bootstrap 官网:http://getbootstrap.com/

2、bootstrap 中文官网:http://v3.bootcss.com/

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'attribute' => 'status',
                // 使用匿名函数添加 css 样式
                // bg-danger 这个样式在 bootstrap 中文官网 -> 全局 css 样式 -> 辅助类 -> 情景背景色
                'contentOptions' => function($model){
                    return ($model -> status == 1) ? ['class' => 'bg-danger'] : [];
                },
            ],
        ],
    ]); ?>

 

 注:本文为作者(44106-kangaroo) 看完魏羲教你学Yii2.0 视频后所记,如有转载请注明出处:http://www.cnblogs.com/chrdai/p/7994471.html

 

相关文章:

  • 2021-08-22
  • 2021-06-03
  • 2021-12-24
  • 2022-12-23
  • 2021-12-22
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-31
  • 2021-11-17
  • 2022-01-10
  • 2021-09-16
  • 2022-12-23
  • 2021-12-05
相关资源
相似解决方案