There are also differences between the various CSS selectors and the introduction of style sheets. import a style sheet to introduce some pseudo-class selectors and import selectors.
(1) CSS selector:
1. Tag Selector:Select the tag directly using the HTML Tag Name
2. class selector:The. selector name {} is
Summary: Pseudo-Class (Pseudo classes) is a bolt of a selector that specifies the state of one or its associated selectors. They are in the form of Selector:pseudo class {Property:value;}, and simply use a half-width colon (:) to separate the selectors from the pseudo-class. CSS Many of the suggestions are not supporte
Addclass (class)-Add the specified class name for each matching element.Parameter: Class-names of one or more CSS classes to be added to an element. Separate them with spaces (string)Example 1:Add the 'selected' class to the matched element.HTML code:Jquery code:$ ("P"). add
CSS pseudo-ClassThe pseudo-class in CSS syntax is used to add special effects to certain selectors. Common pseudo-classes are:(1) syntaxSyntax for pseudo-classes:Selector:pseudo-class {Property:value}CSS classes can also be used in conjunction with pseudo-classes.Selector.cl
Although the CSS code has been written to use the class name to mark the elements, but this is more of their own habits, today to do a summary of the problem.Here are the specific reasons why this is doneOne: The class class name of the element can have many, and the ID name only has one. By adding multiple
About positioning in CSS using sub-parent (subclass absolute position and parent class relative position)
Foreword: Recently in learning Javaweb front-end CSS, about the positioning of CSS may sometimes be used to the sub-father, due to my limited level if there is any place to say wrong, please point out that
(a) CSS selector:
1. Tag Selector: Select the tag directly from the HTML tag name
2. Class Selector: Select the label with the class attribute added by the name {} of the. Selector
3.ID selector: Select the tag with the id attribute added by the # selector name {}, which is the only one in the HTML document
4. Universal selector: Select all the tags in the HTML
defined: Before and: After pseudo-elements interact with replaceable elements, such as IMG in HTML. This is defined in detail in future specifications. (The specification here refers to CSS2.1).D. The code below, using pseudo-elements to clear the float. (Here's a question about why you should set visibility, font-size, height, zoom, and so on.) I still cleared the float after I removed these properties under Chrome browser). clearfix:after {visibility:hidden;display:block;font-size:0;content:
CSS Class and ID selector, CSSClassID Selector
9. CSS Class and ID Selector
The difference between id and class indicates that the same ID of a page can only be used once, but the class can be used without restriction.Similarly, y
Core Tip: first understand the pros and cons of IDs and class. So that they can be used according to their own characteristics.
Which one do you want to use for ID and class?The first thing to understand is the pros and cons of IDs and class. So that they can be used according to their own characteristics.
Advantages of ID (
-align:center;padding-top:5px;} #level4 {border:1px solid gray;width:20px;height:20px;float:left;color:green; margin-right:5px;text-align:center;padding-top:5px;} #level5 {border:1px solid gray;width:20px;height:20px;float:left;color:blue; margin-right:5px;text-align:center;padding-top:5px;}
The effect of Figure 1 can now be completed.
Third, interactive style implementation
Next, by analyzing demand 2, we found that as long as you clicked on each Li element, you gave the element a bold an
CSS basics 5: class selector
I CSS class selector Overview
The class selector allows you to specify styles in a way independent of document elements. This selector can be used independently or in combination with other elements.
These selectors can only be used after the doc
Css
In CSS, pattern matching rules determine which element of the document tree The style rule applies to. These patterns are called selectors (selector). A CSS rule is a selector {property: Value; property: Value;} (Selector {property:value;property1:value2;} , that is, the selector determines which element the declaration (declaration) in {} matches.
The select
In addition to selecting elements based on the ID (#), Class (.), attributes ([]), the element selector for CSS has an important category, which is to select elements based on their special state. They are pseudo-classes and pseudo-elements. Unlike the ID selector, class selector, property selector, and derived selectors, and so on, these get elements from the HT
. example. pp{ Color:orange;}. example.pp2 { color:green;}
As in the above two definitions one is the middle there are spaces, one is the middle no space.
The first class to write to this effect:
Excuse me, why is this??
. example. PP = E F is a descendant selector.
The. Example.pp2 is an element on which the element includes these two classes to be effective.
There is a difference between the two, there is a big difference!
Example. PP is separate
CSS size: Allows you to control the height and width of the element. Again, you are allowed to increase the line spacing.
CSS classification: Allows you to control how elements are displayed, where the image is displayed in another element, position the element relative to its normal position, use absolute values to position the element, and the visibility of the element.
This article brings to you the content is about the CSS pseudo-class selector and pseudo-element selector introduction (with code), there is a certain reference value, the need for friends can refer to, I hope you have some help.
First, link pseudo-class
1. Link pseudo-Class
/* Link pseudo-
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.