如何生成自定义高度的文本字段(yii textField) [英] how to generate a textfield with customized height (yii textField)
问题描述
大家好,感谢阅读.我有这个
Hello everybody and thanks for reading. I have this
<?php
echo $form->textField($model, 'link', array(
'prepend' => '<i class="icon-4x icon-globe" style="line-height: 54px;"></i>',
'class' => 'span12', 'maxlength' => 999,
'height'=>100,
'htmlOptions' => array('style' => 'height:60px;font-size: 22px;')
));
?>
这对宽度不起作用但是当我用高度替换它时它不起作用.没有其他 css 规则覆盖它.如何在 yii 中的文本文件上设置自定义高度
This is not working for width but when i replace it with height its not working. There is no other css rules that overwrite it . How can i set a custom height on a textfiled in yii
推荐答案
来自 yii docs一个>:
public string textField(CModel $model, string $attribute, array $htmlOptions=array ( ))
所以你应该有:
$form->textfield($model,'link',array('style'=>'width:600px;'));
我看到你还有一门课:
$form->textfield($model,'link',array('style'=>'width:600px;', 'class' => 'class_x'));
现在,让我解释一下您的代码中发生了什么:
now, let me explin what happens within your code:
echo $form->textField($model, 'link', array(
'prepend' => '<i class="icon-4x icon-globe" style="line-height: 54px;"></i>',
'class' => 'span12', 'maxlength' => 999,
'height'=>100,
'htmlOptions' => array('style' => 'height:60px;font-size: 22px;')
));
第一个和第二个参数没问题
the first and second parameters are ok
说到第 3 个,一开始看起来还不错,因为它是一个数组,代表文档中的 htmlOptions 数组
when it comes to the 3rd one, at first it looks fine, because it is a array, that represents the htmlOptions array from the documentation
如果你深入挖掘,你会看到在 htmlOptions 数组中你有另一个 htmlOptions 数组;为什么?
if you digg deeper, you see that in the htmlOptions array you have another htmlOptions array; WHY?
这样写:
echo $form->textField($model, 'link', array(
'prepend' => '<i class="icon-4x icon-globe" style="line-height: 54px;"></i>',
'class' => 'span12',
'style' => 'height:60px;font-size: 22px;width:999px;',
));
这篇关于如何生成自定义高度的文本字段(yii textField)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!