Categories: CSS属性

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-xhr="#">
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-xhr="#">
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

这个人很懒,什么都没有留下~

Share
Published by
terry

Recent Posts

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

6 天 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

2 周 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

2 周 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

3 周 ago

聊聊React和Vue组件更新的实现及区别

React 和 Vue 都是当…

4 周 ago