我找了又找,但还是不太明白。我在我的网站上有一个文本框,在我的CSS/HTML中,我给它定义了一个类,就像其他任何东西一样,并给它一个背景图像,没有问题。我决定我需要改变字体颜色,但无论我做什么,它就是不起作用。
我的文本框CSS是:
.tb1 {
background-color : #505050;
background-image: url(images/mb_btn2.jpg);
color: 0090ff;
border-style: none;
onfocus="this.value=''
}
...this似乎不太起作用。
我读了别人对一个类似问题的回复,上面写着使用
onfocus="this.value=''
它没有做任何事情,然后我尝试了,一个占位符:
<input name="username" type="text" class="tb1" maxlength="24" placeholder="Username"/>
这在某种程度上是有效的。它在文本框中放入一个蓝色的“用户名”。但我必须擦除它才能开始打字,当你打字时,它仍然是黑色的,而且不是定义的颜色。
这是HTML表单:
<div id="login" class="login"><center>
<form action="login.php" method="post">
Username:<br><input name="username" type="text" class="tb1" placeholder="Username"<br/>
Password:<br><input class ="tb1" type="password" name="password" placeholder="Password"/><br />
<input class="tb1" type="submit" name="login" value="Login"/>
</form></center>
</div>
那么怎样才能改变我的文本框的颜色呢?和/或当您单击它时将其清除,这样“用户名”或“密码”就会被清除,您可以输入您的信息,而不必在input?...oh和提交按钮之前自行擦除它
发布于 2014-02-11 11:44:58
你错过了#
:color: #0090ff;
发布于 2014-02-11 11:55:23
<div id="login" class="login">
<form action="login.php" method="post">Username:
<br>
<input name="username" type="text" class="tb1" placeholder="Username"/> <br/>Password:
<br>
<input class="tb1" type="password" name="password" placeholder="Password" />
<br />
<input class="tb1" type="submit" name="login" value="Login" />
</form>
</div>
CSS
.login
{
width:250px;
margin:0px auto;
}
.tb1 {
background-color : #505050;
background-image: url(images/mb_btn2.jpg);
color: #0090ff;
border-style: none;
}
在您的代码中使用了<center>
,请不要使用它,它已被弃用。
发布于 2014-02-11 11:47:23
您的十六进制颜色声明缺少#
。将其更改为color: #0090ff;
https://stackoverflow.com/questions/21692594
复制相似问题