CSS选择器

行内样式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS行内样式</title>
</head>
<body>
    <h3 style="color: #00FF00; ;">千珏</h3>
    <h3 style="color: #73FF16; ;">亚索</h3>
    <h3 style="color: #76f019; ;">剑魔</h3>
</body>
</html>

内部样式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS行内样式</title>
    <style>
        /*内部样式*/
        h3{
            color: #00FF00;
        }
    </style>
</head>
<body>
    <h3>千珏</h3>
    <h3>剑魔</h3>
    <h3>青钢影</h3>
</body>
</html>

 外部样式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS外部样式</title>
    <link rel="stylesheet" href="./CSS/外部样式.css">
</head>
<body>
    <h3>千珏</h3>
    <h3>剑魔</h3>
    <h3>青钢影</h3>
</body>
</html>
 /*外部样式*/
 h3{
    color: #00FF00;
}

CSS标签选择器 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>标签选择器</title>
    <style>
        p{
            color: rgb(191, 238, 22);
            font-size: 66px;
        }
    </style>
</head>
<body>
    <p>千珏</p>
</body>
</html>

类选择器

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类选择器</title>
    <style>
         p{
            color: rgb(191, 238, 22);
            font-size: 10px;
        }
        .buzhidao{
            font-size: 30px;
            color: red;
        }        
    </style>
</head>
<body>
    <p class="buzhidao">千珏</p>
    <p class="buzhidao">剑魔</p>
    <p>青钢影</p>
</body>
</html>

 id选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>id选择器</title>
    <style>
         p{
            color: rgb(191, 238, 22);
            font-size: 10px;
        }
        .buzhidao{
            font-size: 30px;
            color: red;
        }    
        #qianjue{
            color: aqua;
            font-size: 16px;
        }    
    </style>
</head>
<body>
    <p class="buzhidao">千珏</p>
    <p class="buzhidao" id="qianjue">剑魔</p>
    <p>青钢影</p>
</body>
</html>

后代选择器

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后代选择器</title>
    <style>
        ul a {
            text-decoration: line-through;
        }
    </style>
</head>

<body>
    <a href="">00</a><br>

    <ul>
        <a href="">22</a>
        <a href="">33</a>
        <li><span><a href="">11</a></span></li>
        <li><span><a href="">11</a></span></li>
    </ul>
    <a href="">00</a>

</body>

</html>

 

 直接相邻选择器

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字节相邻选择器</title>
    <style>
        #two+p {
            color: red;
            background-color: black;
            font-size: medium;
            font-weight: 100;
            font-family: 'Courier New', Courier, monospace;
        }
    </style>
</head>

<body>
    <span>
        <p>x熊大</p>
        <p id="two">x熊二</p>
        <p>x熊三</p>
        <p>x熊四</p>
        <p>x熊五</p>
    </span>
</body>

</html>

 间接相邻选择器

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>间接相邻选择器</title>
    <style>
        #two~p {
            color: red;
            background-color: black;
            font-size: medium;
            font-weight: 100;
            font-family: 'Courier New', Courier, monospace;
        }
    </style>
</head>

<body>
    <span>
        <p>x熊大</p>
        <p id="two">x熊二</p>
        <p>x熊三</p>
        <p>x熊四</p>
        <p>x熊五</p>
    </span>
    <p>熊六</p>
</body>

</html>

 属性选择器

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性选择器</title>
    <style type="text/css">
        input[type=text]{
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
    <input type="text"  name="" id="" value="" placeholder="请输入账号" >
    <input type="password" name="" id="" value="" placeholder="请输入密码">
</body>
</html>

 公共选择器

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公共选择器</title>
    <style type="text/css">
        input[type=text],
        input[type=password]{
            width: 100px;
            height: 100px;
        }
        input[type=text]{
            border: 0.1rem solid #000;
        }
        input[type=password]{
            border: 0.1rem solid #0f0;
        }
    </style>
</head>
<body>
    <input type="text"  name="" id="" value="" placeholder="请输入账号" >
    <input type="password" name="" id="" value="" placeholder="请输入密码">
</body>
</html>

 通配符选择器

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通配符选择器</title>
    <style type="text/css">
        * {
            color: rgb(249, 100, 0);
            background-color: rgba(245, 228, 4, 0.541);
            font-size: 10px;
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <a href="">点点我试试看呗</a>
        </li>
    </ul>
    <p>执子之魂</p>
    <span>与子共生</span>
</body>

</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值