2015-04-01 67 views
0

這是我的代碼:如何在Yii中添加內聯CSS來下拉菜單?

<?php echo $form->dropDownList($model, 'type', CHtml::listData($ab->type, 'id', 'name'), array('class' => 'edit'), array('width:165px')); ?> 

我試圖內聯CSS添加到我的下拉列表中,但我的例子不工作。爲什麼?

+0

你有沒有嘗試這個辦法:陣列( '風格'=> '寬度:165像素') – 2015-04-01 14:15:31

+0

我試過了,但仍然不工作 – 2015-04-01 14:18:07

+0

好吧..這個?數組('class'=>'edit','style'=>'width:165px') – 2015-04-01 14:25:16

回答

2

它應該是這樣的:

<?php echo $form->dropDownList($model, 'type', CHtml::listData($ab->type, 'id', 'name'), array('class' => 'edit', 'style' => 'width:165px')); ?> 
0

This should work

<?php echo $form->dropDownList($model, 'type', CHtml::listData($ab->type, 'id', 'name'), array('class' => 'edit', 'style'=>'width:165px;')); ? 
+0

最好是投票以前的答案,而不是發佈完全相同的答案。 – hamed 2015-04-01 14:29:19