12、其他伪类选择器 - HTML5&CSS3.0基础部分-xyphf-CSDN博客

46 阅读1分钟

1.选取没有子元素子节点的元素

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
<style>
li:empty{background:red;}
</style>
</head>
<body>
<ul>
     <li>aaa</li>
     <li></li>
     <li><div></div></li>
     <li>     </li>
     <li>bbb</li>
     <li>ccc</li>
</ul>
</body>
</html>

2.input选中状态选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
<style>
input:checked{width:100px;height:100px;}
</style>
</head>
<body>

<input type="radio" />
<input type="radio" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
</body>
</html>

3.不可使用选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
<style>
input:disabled{background:red;}
</style>
</head>
<body>
    <input disabled type="text" value="text" />
    <input disabled type="text" value="button" />
</body>
</html>