CSS3 :target 选择器
Highlight active HTML anchor:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
:target {
border: 2px solid #D4D4D4;
background-color: #e5eecc;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p><a href="#news1">Jump to New content 1</a></p>
<p><a href="#news2">Jump to New content 2</a></p>
<p>Click on the links above and the :target selector highlight the current active HTML anchor.</p>
<p id="news1"><b>New content 1...</b></p>
<p id="news2"><b>New content 2...</b></p>
<p><b>注意:</b> IE 8 以及更早版本的浏览器不支持 :target 选择器.</p>
</body>
</html>
定义和用法
# 锚的名称是在一个文件中链接到某个元素的URL。元素被链接到目标元素。
:target选择器可用于当前活动的target元素的样式。
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
选择器 | |||||
---|---|---|---|---|---|
:target | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |