css选择器

<!--css选择器.html-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>css选择器</title>
    <!--css:层叠样式表。写在style标签中,或.css文件中。style标签常位于head标签中,title标签后。css文件使用link标签链接。-->
    <link rel="stylesheet" href="css样式表.css">   <!--链接外部样式表,优先级最低-->
    <style>                             /*写于style标签中的样式称为内部样式,其优先级高于外部样式*/
        /*css注释:标签选择器:标签名{}*/
        a {
            background-color: green;
            font-size: 20px;
            font-family: 黑体;
        }
        /*id选择器: #id{}*/
        #div1 {
            background-color: cyan;
            color: blue;
            font-size: 10px;
            width: 100%;
            height: 200px;
        }
        /*class选择器: .class{}*/
        .title {
            color: red;
        }
        /*层级选择器: 选择器 选择器 ...{}*/
        div p{
            color: green;
        }
        .title p{
            color: blue;
            font-size: 10px;
        }
        /*伪类选择器: 选择器:hover{},鼠标移动到其上时才作用*/
        a:hover {
            background-color: white;
            font-size: 50px;
            color: gold;
        }

    </style>
</head>
<body>
    <h1 class="title">
        css选择器
        <p>————选择器 {属性:值;属性:值;...}</p>
    </h1>
    <div id="div1">
        <h1>蓝色</h1>
        <a href="">跳转</a>
        <p>蓝色</p>
    </div>

    <div class="content">
        <!--写于开始标签的style样式称为行内样式,其优先级最高。-->
        <span style="font-size: 40px; color: green;">太阳</span>一如既往的白,悬浮在东方的高空中,让人不敢直视。
    </div>
    <!--四种选择器的优先级由作用范围决定,实际范围小的优先级越高-->
    <div id="div1">
        <h2>应用id选择器样式</h2>
        <h3 class="title">
            应用class选择器样式
            <div id="div1">应用id选择器样式</div>
            <a>应用标签选择器样式</a>
            <p>应用层级选择器样式</p>
        </h3>
        <a>
            应用标签选择器样式
            <div id="div1">
                <p>应用层级选择器样式</p>
            </div>
        </a>
        <p>应用层级选择器样式</p>
    </div>
</body>
</html>
/*css样式表*/
.content{
    font-size: 15px;
    font-family: 宋体;
    font-weight: normal;
}
a {
    color: yellow;
    font-size: 40px;
    font-family: 楷体;
        }
posted @ 2021-01-16 13:24  流水自净  阅读(56)  评论(0编辑  收藏  举报