Adjust the order of the CSS types change the link rollover effect

Source: Internet
Author: User
Tags access
Css| links you may have realized that you can create a CSS rollover effect by specifying a different style for each key link, which includes normal link (normal), access, flip, and activate. And, you may also know that the order of CSS types can have an effect difference, and the style of the CSS code will replace the style of the previous order for the same element. It is important to establish the type Order of tumbling effects.

Now let's see how to schedule the type of link state to support normal rollover effects without conflict, and how to rearrange these type orders to get a different rollover effect.

Link State

A typical CSS rollover effect relies on a standalone type of one of the four states in the hyperlink. You can create a (hyperlink) type that comes with a CSS preset class to specify the link state:

a:link--General, non-access hyperlinks

a:visited--Access to hyperlinks

a:hover--the link when the visitor operates the mouse

a:active--Click on the link

In order to make a typical CSS rollover work, the CSS type Order in CSS code is important, whether it's an external type table or a type rule embedded in the HIML page title bar.

The A:link type occurs as early as it can be applied to all links. The a:visited type is ranked second, and it replaces any linked a:link format. (If the A:link type follows the A:visited,a:link, the a:visited type may be substituted.) followed by the a:hover type, which is used only to access the link under the mouse. The last is a:active, so when the link is clicked, it can replace all other types.

a:link {

Color: #0000FF;

Text-decoration:underline;

Font-weight:normal;

Font-style:normal;

}

a:visited {

Color: #3399FF;

Text-decoration:underline;

Background-color: #FFFFFF;

Font-weight:normal;

Font-style:italic;

}

a:hover {

Color: #0000FF;

Text-decoration:underline;

Background-color: #FFFF00;

Font-weight:bold;

Font-style:normal;

}

a:active {

Color: #FF0000;

Text-decoration:none;

Background-color: #CCCCCC;

Font-weight:bold;

Font-style:normal;

}

The type Order in CSS code determines how each type replaces other types, that is, that more types can be applied to a particular element. Normally, the a:hover type is behind the A:link and a:visited types, so the type of hover state can be applied to regular and access links. However, it does not have to follow this approach, you can change the type order to achieve different effects.

Suppose you want to use rollover effects in non-access links, but don't want to affect other access links, you might think of code to handle this form change, but all you have to do is rearrange the CSS code.

You can remove the rollover effect from the access link by simply removing the a:visited type.

Note that the a:visited type contains rules that specify all the same attributes as a:hover, otherwise any a:hover-type attributes that are not replaced by the a:visited type will continue to reappear when the visitor's mouse passes through an access link.



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.