1、Target選擇器
:target 選擇器可用于選取當前活動的目標元素
2、效果演示
源代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS-選擇器-Target</title>
<style type="text/css">
a{
text-decoration: none;
}
:target{
background: red;
width: 200px;
height: 200px;
}
</style>
</head>
<body>
<a href="#id1">跳轉到內容1</a><br/>
<a href="#id2">跳轉到內容2</a><br/>
<a href="#id3">跳轉到內容3</a><br/>
<a href="#id4">跳轉到內容4</a><br/>
<a href="#id5">跳轉到內容5</a><br/>
<div id="id1">內容1</div>
<div id="id2">內容2</div>
<div id="id3">內容3</div>
<div id="id4">內容4</div>
<div id="id5">內容5</div>
</body>
</html>
運行效果:(交互效果,需要保持代碼,自行體驗)
image.png