返回到:CSS 伪类(Pseudo-classes) | CSS教程
定义和用法
:disabled 选择器匹配每个禁用的的元素(主要用于表单元素)。
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
| 选择器 | 谷歌 | IE | 火狐 | 苹果 | opera |
|---|---|---|---|---|---|
| :disabled | 4.0 | 9.0 | 3.5 | 3.2 | 9.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/5341.html
支付宝
微信