


CSS3 selectors (basic selectors, attribute selectors, pseudo-class selectors, selector strategies)_html/css_WEB-ITnose
《CSS3 Basic Selector》
<p class="sycode"> <p class="sycode"> 一、通配符选择器(*) </p> <p class="sycode"> *{ </p> <p class="sycode"> marigin: 0; </p> <p class="sycode"> padding: 0; </p> <p class="sycode"> } </p> <p class="sycode"> </p> <p class="sycode"> 二、元素选择器(E) </p> <p class="sycode"> li {background-color: grey;color: orange;} </p> <p class="sycode"> </p> <p class="sycode"> 三、类选择器(.className) </p> <p class="sycode"> </p> <p class="sycode"> 四、id选择器(#ID) </p> <p class="sycode"> #first {background: lime;color: #000;} </p> <p class="sycode"> #last {background: #000;color: lime;} </p> <p class="sycode"> </p> <p class="sycode"> 五、后代选择器(E F) </p> <p class="sycode"> .demo li {color: blue;} </p> <p class="sycode"> </p> <p class="sycode"> 六、子元素选择器(E>F) </p> <p class="sycode"> ul > li {background: green;color: yellow;} </p> <p class="sycode"> </p> <p class="sycode"> 七、相邻兄弟元素选择器(E + F) </p> <p class="sycode"> li + li {background: green;color: yellow; border: 1px solid #ccc;} </p> <p class="sycode"> </p> <p class="sycode"> 八、通用兄弟选择器(E ? F) </p> <p class="sycode"> .active ~ li {background: green;color: yellow; border: 1px solid #ccc;} </p> <p class="sycode"> </p> <p class="sycode"> 九、群组选择器(selector1,selector2,...,selectorN) </p> <p class="sycode"> .first, .last {background: green;color: yellow; border: 1px solid #ccc;} </p> </p>
《CSS3 Attribute Selector》
CSS3 attribute selectors mainly include the following types:
- E[attr]: only uses the attribute name, but does not determine any attribute value;
- E[attr="value"]: Specifies the attribute name, and specifies the attribute value of the attribute;
- E[attr~="value"]: Specifies the attribute name, and has the attribute value, This attribute value is a word list separated by spaces. The word list contains a value word, and the "?" in front of the equal sign must be written;
- E[attr^="value" ]: The attribute name is specified, and there is an attribute value, and the attribute value starts with value;
- E[attr$="value"]: The attribute name is specified, and there is an attribute value, and the attribute value is Ending with value;
- E[attr*="value"]: The attribute name is specified, and there is an attribute value, and the attribute value contains value;
- E[attr|= "value"]: The attribute name is specified, and the attribute value is value or a value starting with "value-" (for example, zh-cn);
-
<p class="sycode"> <p class="sycode"> .demo a[href][title] {background: yellow; color:green;}//存在href 和title 被选中 </p> <p class="sycode"> .demo a[id="first"] {background: blue; color:yellow;font-weight:bold;}//id="first"被选中 </p> </p>
《CSS3 Pseudo-Class Selector》
1. This is the most commonly used dynamic pseudo-class
<p class="sycode"> <p class="sycode"> .demo a:link {color:gray;}/*链接没有被访问时前景色为灰色*/ </p> <p class="sycode"> .demo a:visited{color:yellow;}/*链接被访问过后前景色为黄色*/ </p> <p class="sycode"> .demo a:hover{color:green;}/*鼠标悬浮在链接上时前景色为绿色*/ </p> <p class="sycode"> .demo a:active{color:blue;}/*鼠标点中激活链接那一下前景色为蓝色*/ </p> </p>
2. UI element status pseudo-class
":enabled",":disabled",":checked "Pseudo-classes are called UI element state pseudo-classes. These are mainly used for Form element operations in HTML. The most common one is that our "type="text" has two states: enabled and disabled. The former is a writable state and the latter is Not available; in addition, "type="radio" and "type="checkbox"" have two states: "checked" and "unchecked". Let's look at two examples. For example, if you want to distinguish the "disabled" text box from other text boxes, you can apply it like this;
IE6-8 does not support ":checked", ":enabled" ",":disabled" these three selectors
3. :nth selector
4 , Negative selector (:not)
The negative selector is exactly the same as the :not selector in jq. Just use the elements in the form to illustrate the usage of this selector. For example, if you want to Add borders to all inputs, but you don’t want the submit to change. You can use :not to implement
<p class="sycode"> <p class="sycode"> input:not([type="submit"]) {border: 1px solid red;} </p> </p>
5. Pseudo element
Everyone has seen pseudo elements in CSS before: :first-line, :first-letter, :before, :after; then in CSS3, he has made certain changes to pseudo elements. Based on the previous adjustment, a ":" was added, which now becomes "::first-letter,::first-line,::before,::after". In addition, he also added a "::" selection", two "::" and one ":" are mainly used to distinguish pseudo classes and pseudo elements in CSS3. So far, both methods are accepted, which means that no matter which writing method is used, The functions are the same, but the writing format is different.
Then let’s briefly understand their functions
::first-line selects the first line of the element. For example, to change the style of the first line of text in each paragraph, we can use this.
::before和::after这两个主要用来给元素的前面或后面插入内容,这两个常用"content"配合使用, 见过最多的就是清除浮动
<p class="sycode"> <p class="sycode"> .clearfix:before, </p> <p class="sycode"> .clearfix:after { </p> <p class="sycode"> content: "."; </p> <p class="sycode"> display: block; </p> <p class="sycode"> height: 0; </p> <p class="sycode"> visibility: hidden; </p> <p class="sycode"> } </p> <p class="sycode"> .clearfix:after {clear: both;} </p> <p class="sycode"> .clearfix {zoom: 1;} </p> </p>
《CSS选择器优化》
固有效率:

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool