如何更改表单域的默认背景颜色

时间:2015-10-03 12:12:22

标签: html5 css3

这是我的表格(Yii2)

<?php $form = ActiveForm::begin(); ?>

        <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>

        <?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?>

        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Login') : Yii::t('app', 'Update'), 
        ['class' => $model->isNewRecord ? 'btn btn-success btn-block btn-lg' : 'btn btn-primary']) ?>

<?php ActiveForm::end(); ?>

当我运行这个时,我得到一个黄色背景的表格。我想要一个白色的背景。所以我使用了以下css

background-color: white !important;

但它不起作用。用户代理样式表具有此值

input:-webkit-autofill, textarea:-webkit-autofill {
background-color: rgb(250, 255, 189);
background-image: none;
color: rgb(0, 0, 0);
}

我认为这个值会导致我脸色变黄。但我用白色改变它并没有解决我的问题。 enter image description here

1 个答案:

答案 0 :(得分:0)

使用用户代理样式表用于覆盖您自己的CSS中的值的相同选择器:

input:-webkit-autofill, textarea:-webkit-autofill { background-color: white; }

否则它将无效,如果您的选择器(您没有向我们展示顺便说一句。)不太具体。

你可能想要考虑的其他事情:

此特殊格式用于向用户表明他们已在浏览器的密码管理器中实际保存了此表单的登录数据。因此,出于简单的“审美”原因,将这一重要的视觉线索从它们中移除可能不是最明智的选择。

相关问题