本文介绍了在 gridview yii2 中设置宽度图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
如何在 yii2 中的 gridview 小部件中设置宽度图像?
我一直在使用这种方法来显示图像.yii2 中 gridview 中的图像
解决方案
你可以像例子一样为单元格定义类
<预><代码>['属性' =>'标题','格式' =>'图片','价值' =>函数($数据){返回'you_image.jpeg';},'内容选项' =>['类' =>'来上课']],然后使用css设置图像宽度.如果图片宽度可以不同,使用html格式
<预><代码>['属性' =>'标题','格式' =>'html','价值' =>function($data) { return Html::img('you_image.jpeg', ['width'=>'100']);},],how to set width image in gridview widget in yii2?
I've been using this method to display the image. Image in gridview in yii2
解决方案
You can define class for cells as in example
[
'attribute' => 'title',
'format' => 'image',
'value' => function($data) { return 'you_image.jpeg'; },
'contentOptions' => ['class' => 'come-class']
],
Then set image width using css. If image width can be different, use html format
[
'attribute' => 'title',
'format' => 'html',
'value' => function($data) { return Html::img('you_image.jpeg', ['width'=>'100']); },
],
这篇关于在 gridview yii2 中设置宽度图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)