Yii2 girdview 列中内容过长调整 truncate text
新增样式
.truncate { max-width: 150px !important; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .truncate:hover{ overflow: visible; white-space: normal; width: auto; }
对应的列应用属性
[ 'attribute' => 'subject', 'contentOptions' => ['class' => 'truncate'], ],
效果就是:超过150px 自动用 ...代替,鼠标经过会全部显示
评论区
请登陆 后评论!