Home Web Front-end CSS Tutorial Adjust the order of CSS types to change the link scrolling effect_CSS/HTML

Adjust the order of CSS types to change the link scrolling effect_CSS/HTML

May 16, 2016 pm 12:11 PM

You may have realized that you can create CSS scrolling effects by specifying different styles for each link, including normal link (normal), access, flip, and activation. Also, you may also know that the order of CSS types can make a difference in performance. Post-order styles of CSS code will replace pre-order styles for the same element. The order in which types of roll effects are created is very important.
Now let’s see how to arrange the types of link state to support normal tumbling effects without causing conflicts, and how to rearrange the order of these types to obtain different tumbling effects.

Link status

Typical CSS scroll effects rely on independent types of one of four states in a hyperlink. The (hyperlink) type can be created with a CSS pre-class to specify the link status:

a:link - regular, non-accessible hyperlink

a:visited——Visited hyperlink

a:hover - the link when the visitor moves the mouse through

a:active——Click the link

In order for the typical CSS scrolling effect to work properly, the order of CSS types in the CSS code is very important, whether it is an external type table or a type rule embedded in the title bar of a HIML page.

The a:link type appears earliest because it can be applied to all links. The a:visited type comes second and will replace the a:link format of any link. (If the a:link type is followed by a:visited, a:link may replace the a:visited type.) Followed by the a:hover type, this type should only be used to access links under the mouse. Finally, there is a:active, so when the link is clicked, it replaces 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 order of types in CSS code determines how each type replaces other types, i.e. more types can be applied to a specific element. Normally, the a:hover type comes after the a:link and a:visited types, so the hover state type can be applied to regular and visited links. However, it doesn't have to be this way, you can change the order of the types to achieve different effects.

Suppose you want to use a scrolling effect on non-visited links, but do not want to affect other visited links, you may think of handling this appearance change through code, but what you have to do is to reorganize the CSS code.

Removing the scrolling effect from visited links can be easily done by removing the a:visited type.

Note that the a:visited type contains rules for specifying all the same attributes as a:hover. Otherwise, when the visitor's mouse passes through a visit link, any a:hover type attributes that are not replaced by the a:visited type will be Will continue to reappear.

Source: Web Teaching Network

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Adding Box Shadows to WordPress Blocks and Elements Adding Box Shadows to WordPress Blocks and Elements Mar 09, 2025 pm 12:53 PM

Adding Box Shadows to WordPress Blocks and Elements

Create a JavaScript Contact Form With the Smart Forms Framework Create a JavaScript Contact Form With the Smart Forms Framework Mar 07, 2025 am 11:33 AM

Create a JavaScript Contact Form With the Smart Forms Framework

Create an Inline Text Editor With the contentEditable Attribute Create an Inline Text Editor With the contentEditable Attribute Mar 02, 2025 am 09:03 AM

Create an Inline Text Editor With the contentEditable Attribute

Working With GraphQL Caching Working With GraphQL Caching Mar 19, 2025 am 09:36 AM

Working With GraphQL Caching

Making Your First Custom Svelte Transition Making Your First Custom Svelte Transition Mar 15, 2025 am 11:08 AM

Making Your First Custom Svelte Transition

Demystifying Screen Readers: Accessible Forms & Best Practices Demystifying Screen Readers: Accessible Forms & Best Practices Mar 08, 2025 am 09:45 AM

Demystifying Screen Readers: Accessible Forms & Best Practices

Comparing the 5 Best PHP Form Builders (And 3 Free Scripts) Comparing the 5 Best PHP Form Builders (And 3 Free Scripts) Mar 04, 2025 am 10:22 AM

Comparing the 5 Best PHP Form Builders (And 3 Free Scripts)

File Upload With Multer in Node.js and Express File Upload With Multer in Node.js and Express Mar 02, 2025 am 09:15 AM

File Upload With Multer in Node.js and Express

See all articles