The Css3:target pseudo-class is used to change the ID style pointed to by the anchor URL in the page, for example, if you want to change the element that the stroke is pointing to #tab the font color is blue, which you can write #tab:target {color:blue}
Browser support:
does not support IE8 and the following version of IE, IE9 support this property, other non-IE kernel browser such as: Firefox, Chrome, and other browsers are supported.
Usage:
: Target pseudo-class with: hover,: Link,: Visited,: The use of pseudo-classes such as focus
: Target {Color:blue}
Example: Css3:target pseudo-Class for tab switching effect
Below is a brief introduction to how to use Csse:target to make a non-javascript tab switch effect
HTML code:
<div class="tablist"> <ul class="tabmenu"> <li><a href="#tab1">标签一</a></li> <li><a href="#tab2">标签二</a></li> <li><a href="#tab3">标签三</a></li> </ul> <div id="tab1" class="tab_content">tab1 content</div> <div id="tab2" class="tab_content">tab2 content</div> <div id="tab3" class="tab_content">tab3 content</div> </div>
CSS code:
. tab_content {Position:absolute;} #tab1: Target, #tab2: Target, #tab3: target {z-index:1;}
The principle is very simple, that is, the tab element is set to absolute positioning absolute, and then through: Target pseudo-class to change their hierarchy (Z-index).