Practical CSS3 Properties: Target Pseudo-class for tab switching effect

Source: Internet
Author: User

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).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.