• 请不要在回答技术问题时复制粘贴 AI 生成的内容
maiziedu
V2EX  ›  程序员

CSS3 学习之伪元素选择器

  •  
  •   maiziedu · Dec 27, 2016 · 2287 views
    This topic created in 3436 days ago, the information mentioned may be changed or developed.

    本文和大家分享的主要是前端开发中, CSS3 伪元素选择器相关用法实例,希望对大家有所帮互助。

    源代码

    <!DOCTYPE html>
    
    <html>
    
    <head>
    
    <meta charset="UTF-8">
    
    <title>not 选择器</title>
    
    <style>
    
        :root{
        
            background: #126fb0;
            
        }
        
        body *:not(h1){
        
            background: #fff;
            
        }
        
        :empty{
        
            background: #ff6600;
            
        }
        
    </style>
    
    </head>
    
    <body>
    
    <h1>not 选择器</h1>
    
    <p>not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器 not 选择器</p>
    
    <br/>
    
    <table border="1" cellpadding="0" cellspacing="0" width="100%">
    
    <tr>
    
        <td>1</td>
        
        <td>2</td>
        
        <td>3</td>
        
        <td>4</td>
        
    </tr>
    
    <tr>
    
        <td>1</td>
        
        <td>2</td>
        
        <td></td>
        
        <td>4</td>
        
    </tr>
    
    <tr>
    
            <td>A</td>
            
        <td>B</td>
        
        <td>C</td>
        
        <td></td>
        
    </tr>
    
    </table>
    
    </body>
    
    </html>
    

    伪元素选择器是什么

    针对于 CSS 中已经定义好的伪元素使用的选择器。伪元素和我们上面的这个伪类,顾名思义它就是假的,那么这个为伪元素的使用方法呢。就是选择器,伪元素{属性:值},那么与类配合使用就是选择器.类名:伪元素{属性:值}

    原文链接: http://www.maiziedu.com/wiki/css3/element/

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1074 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:58 · PVG 06:58 · LAX 15:58 · JFK 18:58
    ♥ Do have faith in what you're doing.