css学习day01

选择器

标签选择器

<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>Document</title>
</head>
<style>
    p {
        color: yellowgreen;
        font-size: 12px;
    }

    div {
        color: pink;
    }
</style>

<body>
    <p>男生</p>
    <p>男生</p>
    <p>男生</p>
    <div>女生</div>
    <div>女生</div>
    <div>女生</div>
</body>

</html>

类选择器

<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>Document</title>
</head>
<style>
    .red {
        color: red;
    }
</style>

<body>
    <ul>
        <li class="red">冰雨</li>
        <li>来生缘</li>
        <li>李香兰</li>
        <li>生僻字</li>
    </ul>
    <div class="red">红色</div>
</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>Document</title>
</head>
<style>
    .box {
        width: 150px;
        height: 100px;
    }

    .red {

        background-color: red;
    }

    .green {

        background-color: green;
    }
</style>

<body>
    <div class="red box"></div>
    <div class="green box"></div>
    <div class="red box"></div>
</body>

</html>

id选择器

只能调用一次

<style>
    #red {
        color: red;
    }
</style>

<body>
    <div id="red">
        12345
    </div>
    <div>
        54321
    </div>
</body>

通配符选择器

<style>
    * {
        color: red;
    }
</style>

<body>
    <div>
        12345
    </div>
    <div>
        54321
    </div>
</body>

css文本属性 

重点属性,查阅更多参见:CSS 教程 (w3school.com.cn)

div{
text-decoration: underline;
}

div{
text-decoration: none
}

css引入方式

内部样式表、行内样式表、外部样式表(重点)

div {
    color: blue;
}
<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>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div>12345</div>
</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值