我有以下代码,
<?php
$this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'customerform-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'name',
array(
'name'=>'logo1',
'header'=>'Logo',
'type'=>'html',
'value'=>'CHtml::tag("img",array("src"=>"/"."$data->logo1"))',
'htmlOptions'=>array('style'=>'width: 50px; text-align: center; height: 50px;'),
),
}
));
?>
的htmlOptions样式只设置表列不为图像,但我想设置的高度和宽度的图像,请帮助我。谢谢你。
你可以在htmlOptions
的style
标签中放置每个css样式:
'value'=>'CHtml::tag("img",array("src"=>"/"."$data->logo1", "style" => "width: 50px; text-align: center; height: 50px;"))',
你可以用另一种方式来处理这个问题。
只要在你的代码中有你想要的class
在PHP中:
array(
'name'=>'logo1',
'header'=>'Logo',
...
'htmlOptions'=>array('class'=>'SimbuClass'
),
)
和应用你的样式在css
In Css:
.SimbuClass
{
width: 50;
height: 50;
text-align: center;
}
你可以在任何你需要的地方重用你的类