如何在视图yii2中设置gridview列的宽度, 参考链接如下,
答案 0 :(得分:4)
试试这个,
<?=
GridView::widget([
'model' => $model,
'options' => ['style' => 'width:80%'],
'attributes' => [
'id',
],
])
?>
答案 1 :(得分:0)
单独设置一列的宽度,如下所示:
[
'attribute' => 'attribute_name',
'headerOptions' => ['style' => 'width:20%'],
],
对于所有列,请尝试:
[
'class' => 'yii\grid\SerialColumn',
'contentOptions' => ['style' => 'width:100px;'],
],