In CSS, there is only one type of color, that is, simple solid color. Also in CSS, you can set the front shadow and background color of any element. What is the foreground of the element? In general, the foreground is the text in the element, but it is not ointment: the border of the element is also considered part of the foreground. This has two ways to directly affect the front shadow color of the element: use the color attribute and one of the border properties to set the border color. The most basic is border-color attribute, as well as some specific properties such as Border-Top, Border-Right, and so on. Background of element refers to space behind all foregrounds until the edge of the border chart, so that the content box and fill are part of the element background.
Foreground color
Color
Allow value:
Initial value: related to the user code
Can you inherit: Yes
Suitable for: all elements
The easiest way to set the foreground is to use the Color property.
For example, let a warning text in a paragraph in green display. as follows:
P.WARN {Color: Red;}
P.WARN A: LINK {Color: Green;
Hello, welcome to Qingqing Seawater blog , let us work together Learn. p>
The display effect is as follows:
Hello, welcome to the blog of Qingqing sea, let us learn together.
Body property
The pseudo class in CSS is used to control the link color in the body, which is really good. Although this feature is implemented in HTML, this function has been implemented, but only CSS is completed for complex link control.
example:
Body {color: black;} / * Set text is black * /
A: Link {color: # 808080} / * Settings link to # 808080 * /
A.External: link {color: # 666} / * Settings the color of the lin EXTERNAL class is # 666 * /
A: Active {color: Silver;} / * Set the color when the link is active is Silver * /
A: Visited {color: # 333;} / * Set the accessible link color to # 333. * /
A: External: visited {color: black;} / * Set the color of the accessible link External class. * /
Moving border
Example: p.Aside {color: gray; border-style: solId;}
I have to keep the moon, I want to find a pure girl in love, I hope I can find a satellite and kindness, responsible single mm, the hand of the child, and the old man, frank. Don't ask for it, but you have no regrets. In the population, I am often quiet!
Similarly, the border color of the image can also be set.
Example: img.type1 {color: gray; border-style: solId;}
Img.type2 {border-color: red; border-style: solId;}
Then the results are as follows:
As can be seen from the above example, the color attribute value can be inherited, such as setting Body is red, except that all texts other than the styled elements are red, but do not affect horizontal line rules (HR) and images element.
background color
Background-color
Allow value:
Can you inherit: No suitable for: all elements
The background refers to the content box and a palden, which is always located behind the foreground. The background color of the declaration will be applied to the content box and the white. example:
P {background-color: gray;}
The effect is as follows:
I have to keep the moon, I want to find a pure girl in love, I hope I can find a satellite and kindness, responsible single mm, the hand of the child, and the old man, frank. Don't ask for it, but you have no regrets. In the population, I am often quiet!
If you want the color to expand outward from the text of the elements, you can only be achieved. as follows:
P {background-color: gray; padding: 10px;}
The effect is as follows:
I have to keep the moon, I want to find a pure girl in love, I hope I can find a satellite and kindness, responsible single mm, the hand of the child, and the old man, frank. Don't ask for it, but you have no regrets. In the population, I am often quiet!
Background image
Background-Image
Allow value:
Initial value: none
Can you inherit: No
Suitable for: all elements
The default none indicates that no image is placed on the background. To get a background image, you can only give a URL value for the property. as follows:
P.BG {Background-Image: URL (http://joke.qq.com/images/joke/200507/19/xhp/15.jpg);
In conjunction with the above example, replace the background color into our current pictures, the effect is as follows:
I have to keep the moon, I want to find a pure girl in love, I hope I can find a satellite and kindness, responsible single mm, the hand of the child, and the old man, frank. Don't ask for it, but you have no regrets. In the population, I am often quiet!
Flexible use of background colors can make more beautiful page effects because it applies to all elements, each element can define background colors.