search
HomeWeb Front-endHTML TutorialCSS3笔记_html/css_WEB-ITnose

CSS3

一、CSS3选择器

  • 基本选择器

    *通配符选择器;
    body,div元素选择器;
    #idID选择器;
    .class类选择器;
    selector1,selector2群组选择器

  • 层次选择器

    E F后代选择器,选择F元素且F被包含于E元素;
    E>F子选择器,选择F元素且为E的子元素;
    E+F相邻兄弟选择器,选择F元素紧邻匹配的E元素;
    E~F通用选择器,选择E后所有匹配F的元素;

  • 动态伪类选择器

    E:link、E:visited链接伪类选择器;
    E:active、E:hover、E:focus用户行为选择器;

  • 目标伪类选择器

    E:target选择匹配E的元素,且匹配元素被相关url指向
    即点击某个链接后,所选元素E的样式可以改变,效果类似进入知乎特定答案链接,该答案背景闪烁。
    除此之外,还可以制作类似手风琴效果,高亮显示区块,tabs,幻灯片,灯箱,相册等效果。

  • 语言伪类选择器

    E:lang(language)
    根据元素的语言编码匹配元素,为文档指定语言有两种方法:

    • 直接设置文档的语言

    • 手工在文档中指定lang属性

  • UI元素状态伪类选择器

    E:checked选中状态
    E:enabled启用状态
    E:disabled不借用状态

  • 结构伪类选择器

    语法
    E:first-child选择E的第一个子元素
    E:last-child选择E的最后一个子元素
    root选择文档根元素,即html
    E F:nth-child(n)选择父元素E的第n个子元素F,n可以使整数、关键字(even、odd),公式(2n+1、-n+5),n的初始值为1
    E F:nth-last-child(n)与上面作用机制相同,但顺序相反
    E:nth-of-type(n)选择父元素内具有指定类型的第n个E元素
    E:nth-last-of-type(n)与上面作用机制相同,但顺序相反
    E:first-of-type
    E:last-of-type
    E:only-child
    E:only-of-type
    E:empty选择没有子元素的E,且该元素也不包含任何文本节点

  • 否定伪类选择器

    :not()选择不满足括号中条件的元素,如footer、:hover、type=radio等

  • 伪元素

    ::first-letter用来选择文本块的第一个字母,一般首字母下沉的效果
    ::first-line选择文本块的第一行文本
    ::before、::after不是存在于标记中的内容,表示可以插入额外内容的位置,生成的内容不会成为DOM的一部分,但同样可以设置样式。
    ::selection设置高亮显示的文本,需要设置background和color两个值;

  • /*webkit,opera9.5+,IE9+*/::selection{    background:blue;    color:white;}/*Mozilla Firefox*/::-moz-selection{    background:blue;    color:white;}

    10. ####属性选择器
    E[attr]选择具有attr属性的E元素,其中E可以省略,表示选择所有定义attr属性的元素,不论类型;
    E[attr=val]选择具有attr属性的E元素,且attr的值为val(区分大小写);
    E[attr|=val]选择具有attr属性的E元素,且attr的值为val或者以val-开头的属性值;
    E[attr~=val]选择具有attr属性的E元素,且attr的值为多个空格分隔的值,其中一个为val
    E[attr*=val]选择具有attr属性的E元素,且attr的值的任意位置包含了val字符串;
    E[attr^=val]选择具有attr属性的E元素,且attr的值为以val开头的任意字符串;
    E[attr$=val]选择具有attr属性的E元素,且attr的值为以val结尾的任意字符串;

    附注:'^'匹配起始符'$'匹配终止符'*'匹配任意字符
    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

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

    HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

    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.

    From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

    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.

    Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

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

    The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

    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.

    HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

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

    HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

    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.

    The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

    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.

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    1 months agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    SecLists

    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.

    DVWA

    DVWA

    Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    Integrate Eclipse with SAP NetWeaver application server.