css3 属性选择器

属性选择:

[id=id1]{

  background-color:red;
}

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			[id=id1]{
				background-color:red;
			}
			[id=id2]{
				background-color:green;
			}
			[id=id3]{
				background-color:blue;
			}
		</style>
	</head>
	<body>
		
		<div id="id1" style="width:200px; height:100px;">
			
		</div>
		<div  id="id2" style="width:200px; height:100px;">
			
		</div>
		<div  id="id3" style="width:200px; height:100px;">
			
		</div>
	</body>
</html>

  效果如图:

 

posted @ 2021-12-15 15:42  艾特-天空之海  阅读(29)  评论(0编辑  收藏  举报