我想更改yii中驗證碼圖片的尺寸。我知道寬度最初設置爲100.我想使它成爲兩倍。下面的代碼我無法更改任何內容。更改yii中驗證碼圖片的尺寸
<?php $this->widget('CCaptcha',array('buttonOptions'=>array('style'=>'width:200')));
我想更改yii中驗證碼圖片的尺寸。我知道寬度最初設置爲100.我想使它成爲兩倍。下面的代碼我無法更改任何內容。更改yii中驗證碼圖片的尺寸
<?php $this->widget('CCaptcha',array('buttonOptions'=>array('style'=>'width:200')));
如果你想改變圖像大小,那麼你應該使用imageOptions
代替buttonOptions
,是這樣的:
<?php $this->widget('CCaptcha', array('imageOptions' => array('style'=>'width:20%'))); ?>
看看在CCaptcha文檔。
您可以自然地實現這一點,而無需設置圖像元素的樣式。在SiteController
中,您有actions()
方法,該方法返回captcha
內置操作的選項數組。
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
'width' => '..' // <- Set this to override a default width
),
然後使其不PARAMS:
<?php $this->widget('CCaptcha'); ?>
通過模板 PHP解決方案:
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>']) ?>
JS:
document.getElementById("reviews-verifycode-image").style.height = "100px";
剛擡起頭,這個綿延圖像到設定的大小 –