Yii2 girdView文本溢出显示...

使用girdView显示文本时,长度过长时,溢出部分使用省略号显示

[
    'attribute'=>'content',
    'label'=>'内容',
    'format'=>'raw',
    'value'=>function($model){
         return "<div style=\"width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis\">".$model->content."</div>";
                    //
    },
],
#此处的思想是通过在td中加一层div将td撑开,在div中对溢出做处理
#需要注意的是format 不能使用html(这点不理解,卡了好久,换成raw就可以)

使用raw效果图

使用html效果图

扫描二维码关注公众号,回复: 3385204 查看本文章

猜你喜欢

转载自blog.csdn.net/benben0729/article/details/82799642