css_sduty/06_CSS复合选择器/06_属性选择器.html
2024-06-29 18:53:19 +08:00

46 lines
1.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>06_属性选择器</title>
<style>
/* 第一种: 选择具有title属性的元素 */
[title] {
color: red;
}
/* 第二种: 选中具有title属性且属性值为zyjblogs2的元素*/
[title="zyjblogs2"] {
color: green;
}
/* 第三种选择title属性值以k开头的元素 */
[title^="k"] {
color: pink;
}
/* 第四种选择title属性值以3结尾的元素 */
[title$="3"] {
color: blue;
}
/* 第五种选择title属性值包含4的元素 */
[title*="4"] {
color: yellow;
}
</style>
</head>
<body>
<div title="zyjblogs1">zyjblogs1</div>
<div title="zyjblogs2">zyjblogs2</div>
<div title="zyjblogs3">zyjblogs3</div>
<div title="k3">k3</div>
<div title="kk">kk</div>
<div title="k4">k4</div>
<div title="l4">l4</div>
</body>
</html>