[Import] CSS again-how to use different styles for elements in different locations

Source: Internet
Author: User

Recently, I have been asked how to use CSS flexibly. Indeed, this is a good phenomenon. Many people have gradually become accustomed to using CSS layout in an all-round way and try to separate presentation from content. However, in the process of getting used to it, you may encounter various difficult problems. One of my experiences is: check more CSS manuals, try more, and ponder over experts' webpages. You can save some pages and analyze them slowly.

Okay, let's get started. There is often a situation where I want to define the hyperlink style at different locations on the same page. For example, I do not want to underline the page navigation section, in other places, underlines are required.

There are two ways to achieve this:

1. You can directly use CSS to specify hyperlinks in different places, for example :. This method is obvious, most powerful, and flexible. The style of any hyperlink on the page is different. However, we do not need to be so flexible, and it is too cumbersome to implement this definition for every hyperlink.

2. The style of hyperlinks is developed in batches using the support of CSS object level. For example, in general, I define hyperlinks on the entire page as underscores, but only menus are not used. You can use the following method:

a{    color:Black;    font-size:12px;    text-decoration:underline;}

If the menu is defined by UL, as described in the previous blog, I can define it as follows:

.Menu a{    color:Black;    font-size:12px;    text-decoration:none;}

The. menu here refers to the CSS used for the menu's outer boundary. In this way, this style is used as long as the hyperlink in this menu is used.

Of course, there are many ways to specify this method. For example:

# Mymenu A {...} indicates all hyperlink styles in the element whose ID is mymenu;

# Mymenu Li a {...} indicates the hyperlink style inside the Li element of the element whose ID is mymenu;

....

A few years ago, Su Shen Xiaoyu wrote a css2.0 manual. You can download it here.


Source: http://community.hf-mstc.org/cs/blogs/shakewang/archive/2006/06/23/2857.aspx

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.