Yii2 Form表单样式修改

本文介绍如何在Yii2框架中对登录表单进行样式调整。通过具体代码示例展示了如何修改表单元素的宽度、高度等属性,并对用户名、密码输入框及记住我选项的样式进行了详细说明。

以下为主要的样式修改的代码,大家可以看着修改。如需要修改类而不是样式,只需要替换style为class即可。

  1. <?php $form = ActiveForm::begin(['action' => ['site/login'], 'method' => 'post']);?>  
  2.     <div style='width:255px;min-height:40px;height:auto;'>  
  3.         <label for='loginform-username' style='margin-right:10px;line-height:2.2em;float:left;'>用户名</label>  
  4.         <?= $form->field($model'username')  
  5.             ->label(false)  
  6.             ->textInput(['style' => 'float:left;width:200px;'])  
  7.             ->error(['style' => 'line-height:2.2em;']); ?>  
  8.     </div>  
  9.     <div style='width:255px;min-height:40px;height:auto'>  
  10.     <label for='loginform-username' style='padding-left:13px;margin-right:10px;line-height:2.2em;float:left;'>密码</label>  
  11.     <?= $form->field($model'password')  
  12.         ->passwordInput()  
  13.         ->label(false)  
  14.         ->textInput(['style' => 'float:left;width:200px;'])  
  15.         ->error(['style' => 'line-height:2.2em;']); ?>  
  16.     </div>  
  17.     <div style='width:255px;min-height:20px;height:auto'>  
  18.         <?= $form->field($model'rememberMe')  
  19.         ->checkBox(['style' => 'flot:left;'])  
  20.         ->label('请记住我', ['style' => 'margin-right:-35px;']); ?>  
  21.     </div>  
  22.   
  23.     <?= Html::submitButton('登录', ['class' => 'btn btn-primary''name' => 'submit-button']); ?> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值