CSS-基础-自学笔记一

<!--
        css 层叠样式表     网页化妆师

        1、如何在网页中引入css代码
            行内式 设置标签的style属性   用的不多,后台喜欢用
                一般少量的样式可以这样写,其他不推荐用,不专业
                <p style="color: brown; background-color: cadetblue;">一段文字</p>
            内嵌式
                在head标签内部放置
                    <style>
                        div {
                            width: 200px;
                            height: 200px;
                            background-color: chocolate;
                        }
                    </style>
                选择器
                    <style>
                        选择器 {
                            k: v;
                            k: v;
                            ...
                        }
                    </style>
                样式不多的情况下采用内嵌式
            外链式
                把css单独放在一个或多个文件
                文件名.css
                    li {
                        list-style: none;
                    }
                只需要在用到样式的网页中引入即可
                <link rel="stylesheet" href="index.css">
    -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: chocolate;
        }
    </style>

    <style>
        /*通配符选择器  一般写在最上边
            *表示所有标签,优先级最低
            */
        
        * {
            background-color: cornflowerblue;
        }
        /*标签选择器    一般对一类标签设置样式*/
        
        h2 {
            color: rgb(226, 23, 23);
        }
        
        a {
            text-decoration: none;
            /*超链接去掉下划线*/
        }
        /*id选择器      用的不多    一般用在独一无二的元素上*/
        
        #box2 {
            background-color: cornflowerblue;
        }
        /*类选择器      用的最多*/
        
        .p1 {
            color: rgb(231, 18, 18);
        }
        /*
        并集选择器
        p div h3 字颜色为红色
        */
        
        p,h3,
        div {
            color: rgb(235, 12, 12);
        }
        /*
        交集选择器
        li.p1   既是li又class是p1
        */
        
        li.p1 {
            text-decoration: underline;
        }
        /*
        后代选择器
        */
        
        div .p1 {
            font-weight: 900;
        }
    </style>
</head>

<body>
    <p style="color: brown; background-color: cadetblue;">一段文字</p>
    <div>
        某一区域
    </div>
    <div>
        <ul>
            <li>hello</li>
            <li>welcome</li>
        </ul>
    </div>

    <h2>段落</h2>
    <h3 id="box2">段落</h3>

    <p class="p1">段落</p>
    <div>
        <ul>
            <li class="p1">北京</li>
        </ul>
    </div>
    <a href="" alt="大王">大王</a>
</body>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值