当用户将鼠标指针放在窗体按钮上时,该按钮必须更改颜色
form button must change color when user place mouse pointer over it
我有以下表格:
<form action="login_form.php" method="POST" id="login_form">
Email <input name="email" type="text" size="25" placeholder="type your email"/>
Password <input name="password" type="text" size="25" placeholder="type your password" />
<input type="submit" value="" name="submit" style="background:url('img/button-go.png') no-repeat; width:68px; height:27px; border:none; cursor:pointer; "/>
</form>
正如您所看到的,我在表单中使用一个名为button-go.png
的图像作为按钮。我还有一个叫button-go_light.png
的按钮。我所想要的只是当用户将鼠标指针放在名为button-go.png
的窗体按钮上方,以更改为button-go_light.png
时。什么是更容易做到这一点的方法,适用于所有探险家?
在css中,您想要的是:DEMO
.btn{
background-image: url('button-go.png');
}
.btn:hover{
background-image: url('button-go_light.png');
}
您需要使用:hover
内联,如下所示:
<form action="login_form.php" method="POST" id="login_form">
Email <input name="email" type="text" size="25" placeholder="type your email"/>
Password <input name="password" type="text" size="25" placeholder="type your password" />
<input type="submit" value="" name="submit" style="{background:url('img/button-go.png') no-repeat; width:68px; height:27px; border:none; cursor:pointer; }:hover {background:url('img/button-go_light.png');}"/>
</form>
<input>
的:hover
在IE6及以下版本中不起作用,因为:hover
只适用于那里的链接。因此,如果您也支持IE6,您将不得不使用JS polyfill,以防您希望<input>
s在悬停时更改bg图像。
相关文章:
- 使用event.target.classlist区分按钮颜色
- 如何使用带有多个按钮的javascript更改按钮颜色
- Highcharts上下文按钮颜色
- 在提交时更改按钮颜色,直到输入新文本
- 如何在javascript中更改按钮颜色
- 根据字段值更改页面加载时的按钮颜色
- 我想在单击时更改按钮颜色和文本,并且在刷新页面时它不应该更改
- 单击另一个按钮后如何更改按钮颜色
- 按钮颜色在切换时不会更改多个按钮
- 默认按钮颜色
- 当我使用jQuery Mobile的UI时,如何在jQuery Mobile中切换单击的导航按钮颜色
- 当管理员在管理面板中获得新任务时,如何更改菜单按钮颜色
- 单击时更改按钮颜色
- 无法更改Bootbox中确认框的按钮颜色
- 更改按钮颜色,即使在单击后也是如此
- 根据表中的另一列更改按钮颜色
- 使用addEventListener切换按钮颜色
- AJAX数据库更新与CSS按钮颜色改变使用Codeigniter
- 单选按钮颜色选择器
- 随着背景颜色的变化而改变按钮颜色