Class is used to define one or more elements according to user-defined standards. A more appropriate example is a script: a class can define the story line of each character in the script. You can use this class through css tutorials and webpage special effects. Therefore, you can use
One of the methods is to change the CSS class of page elements. In traditional JavaScript, we usually implement it by processing the classname feature of HTML Dom; jquery provides three methods to implement this function. Although they share the same idea with traditional methods, they save a lot of effort.
Code . -"Jquery makes JavaScript code concise !"
1. addclass ()-add
9. Class of CSS and ID selectorThe difference between ID and class is that the same ID can only be used once for a page, and class can be unrestricted.Similarly, you can use a selector after the HTML selector to specify special HTML elements, such as the p.jam{value}, to act on the paragraph with the ' Jam '
Class attribute Modification
Class attributes, which are class attributes, specify the name of the classes.When specifying a style with a class selector, you need to specify the class name, which is the value of the class attribu
addclass (Class)-adds the specified class name for each matching element. Parameter: class-one or more CSS class names to add to the element, separated by a space (String)Example one:Add the ' selected ' class to the matched eleme
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
CSS pseudo-classes are special effects that you can use to add some selectors.
GrammarSyntax for pseudo-classes:Selector:pseudo-class {property:value;}CSS classes can also use pseudo-classes:Selector.class:pseudo-class {property:value;}
Anchor pseudo-ClassIn a browser that supports
A pseudo class can be viewed as a special class selector, a special selector that can be automatically recognized by browsers that support CSS. Its greatest use is that you can define different style effects on links in different states.
1. Grammar
The syntax of a pseudo class is to add a pseudo
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
CSS: Cascading style sheet cascading ( [kæ ' Ske?d??] cascading) style SheetCSS BASIC Syntax structure: selector {attribute: value;attribute: value;...}Three main selectors:Tag Selector:A selector named after the HTML tag that directly controls the corresponding labelP{font-size:16;}Class selector:Add the class attribute to the tag, and the selector name is "."
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
(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
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
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
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
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
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.