web前端3

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="CSS/style.css">
    <title>笔记3</title>
    <style>
        /* @import url("CSS/style.css"); */
        div{
            background-color: red;
        }
        *{
            margin: 0;
            padding: 0;
        }
        #wrap{
            width: 200px;
            height: 300px;
            background-color: blue;
        }
        .main{
            width: 200px;
            height: 300px;
            background-color: green;
        }
       
            /* .box p{
                background-color:red;
            }
            .box>p{
                background-color: red;
            } */
            .box{
                width: 200px;
                height: 300px;
            }
            .box:hover{
                background-color: green;
            }
            p::before{
                content: "- 台词";
                background-color: yellow;
                color: red;
                font-weight: bold;
            }
            p::after{
                content: "-台词";
                background-color: yellow;
                color: red;
                font-weight: bold;
            }
        h2,h3{
            width: 200px;
            height: 300px;
            background-color: yellow;
        }

    </style>
</head>
<body>
CSS
    概念:CSS全称为层叠样式表,它主要用于定义HTML内容在浏览器内的显示样式。
    引入方法:
        1.外部样式引入
            link
            @import
        2.内部样式
            代码通常存放在<style></style>标签内
        3.内联样式
        语法:CSS样式由选择符和声明组成,而声明又由属性和值组成
            选择符{属性:值}例:p{color:red;}
            选择符:又称选择器,指明网页中要应用样式规则的元素
        选择器:
            标签选择器  标签名
            类选择器    .加main
            id选择器       #加id名
            通配符选择器    *
            后代选择器      .box p(div标签内所有的p标签渲染)
            子元素选择器    .box>p(子元素渲染)
            群组选择器      h2,h3
            伪类选择器      content: "";可以为空,但是必须存在

<div style="width: 200px; height: 300px; background-color: red;"></div>
<div></div>
<div id="wrap"></div>
<div class="main"></div>
<div class="box">
    <p>子元素中的p</p>
    <ul>
        <li>
            <p>无序列表中的p</p>
        </li>
    </ul>
</div>
<h2>h2标签</h2>
<h3>h3标签</h3>

<p>你好</p>

背景:
    背景颜色:background-color
    背景图片: background-image
    背景图片位置:background-position
    背景图片重复:background-repeat
    背景图片定位:background-attachment:scroll/fixed(默认为srcoll   fixed为随着滚动条得到滚动背景图片不动 )
    一般简写:
    background:#ff0000 url(xxxx.jpg) no-repeat fixed center


1.link和@import的区别(无样式闪烁问题FOUC)
    @import是CSS提供的语法规则,只有导入样式表的作用
    link是HTML提供的标签,不仅可以加载CSS文件,还可以定义RSS,rel链接属性等。

    加载页面时,link标签引入的CSS被同时加载
                @import引入的CSS将在页面加载完毕后被加载

    @import是css2.1才有的语法,故只有在IE5+才能被识别
    link标签作为html元素,不存在兼容性问题

2.三种引入样式的优先级


3.选择符的优先级
    通配符 0;  标签 1;    类/伪类/属性 10;   ID 100;    行内样式 1000;     important 1/0(无穷大)   
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值