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