Css3:target pseudo-Class for tab switching effect

Source: Internet
Author: User

Using: Target pseudo-class to achieve tab switching effect is really very simple! How simple is that? It only requires the following code.

STYLE.CSS:

{    position: absolute;     background: #fff;            }  {    z-index: 1;}

HTML code:

<Divclass= "Song-nav">    <ulclass= "Song-menu">        <Li><ahref= "#song-info">Basic information</a></Li>        <Li><ahref= "#song-LYRICCN">Chinese lyrics</a></Li>        <Li><ahref= "#song-lyricen">English lyrics</a></Li>    </ul></Div><DivID= "SONG-LYRICCN"class= "Song-info">... 3 ...</Div><DivID= "Song-lyricen"class= "Song-info">... 2 ...</Div><DivID= "Song-info"class= "Song-info">... 1 ...</Div>    

Use only Position:absolute; (Applies to toggle content) and : Target pseudo-class is implemented by pointing to the object (target object) display level boost (z-index:1).

Of course, you may think that the code is feasible, but the display effect is too ugly, no matter, give the style is OK.

1. Add a nice border effect to your content

/**/border:1px solid #91a7b4; border-radius:3px;box-shadow:0 2px 3px Rgba (0,0,0,0.1);

2. Navigation menu options Single line display

{    display: inline-block;}

3. Menu options also have a nice border, and the default underline of the link is too ugly, I want to remove!

{    text-decoration: none;     Border: 1px solid #91a7b4;     Border-radius: 0 0 5px 5px;     box-shadow: 0 2px 3px rgba (0,0,0,0.1);}

Note: Open the page, first see is the last Content box content (that is <div id= "Song-info" >), you can see in the navigation bar is the first option. Why did you do it? Because the browser renders the page, because the content is absolutely layout (position:absolute), so the next div to cover the front, so this point to note that you want the first display of the content div on the last side .

Reference Address: Practical CSS3 attribute: Target pseudo-class for tab switching effect

Finish

Css3:target pseudo-Class for tab switching effect

Related Article

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.