CSS3 :enabled 选择器 | CSS 伪类(Pseudo-classes) | CSS教程

返回到:CSS 伪类(Pseudo-classes) | CSS教程

定义和用法

:enabled 选择器匹配每个启用的的元素(主要用于表单元素)。

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

选择器谷歌IE火狐苹果opera
:enabled4.09.03.53.29.6

实例

设置所有type=”text”的启用的输入元素的背景颜色:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Web176教程(web176.com)</title> 
<style> 
input[type="text"]:enabled
{
	background:#ffff00;
}
input[type="text"]:disabled
{
	background:#dddddd;
}
</style>
</head>
<body>

<form action="">
First name: <input type="text" value="Mickey" /><br>
Last name: <input type="text" value="Mouse" /><br>
Country: <input type="text" disabled="disabled" value="Disneyland" /><br>
</form>

</body>
</html>

为所有启用的输入元素设置背景色:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Web176教程(web176.com)</title> 
<style> 
input:enabled
{
	background:#ffff00;
}
input:disabled
{
	background:#dddddd;
}
</style>
</head>
<body>

<form action="">
First name: <input type="text" value="Mickey" /><br>
Last name: <input type="text" value="Mouse" /><br>
Country: <input type="text" disabled="disabled" value="Disneyland" /><br>
Password: <input type="password" name="password" />
<input type="radio" value="male" name="gender" /> Male<br>
<input type="radio" value="female" name="gender" /> Female<br>
<input type="checkbox" value="Bike" /> I have a bike<br>
<input type="checkbox" value="Car" /> I have a car 
</form>
</body>
</html>

作者:terry,如若转载,请注明出处:https://www.web176.com/cssprop/5347.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2022年4月6日 下午5:27
下一篇 2022年4月6日 下午5:36

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注