Blogger Information
Blog 6
fans 0
comment 0
visits 5166
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
css选择器优先级与盒子模型_20190424
下一站
Original
1503 people have browsed it

1. 写一个案例, 演示css中的选择器优先级(忽略js)

//css选择器的优先级: 行内样式 > id选择器 > class选择器 > 标签选择器h1{color:blue;}

实例

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>css选择器的优先级</title>
    <style>
        h1{
            color:red;
        }
        .test{
            color:yellow;
        }
        #test{
            color:blue;
        }
    </style>
</head>
<body>
<!--css优先顺序:style > id > class>定义的标签样式;
    -->
<h1 id="test" class="test" style="color:green">css选择器优先级,style内联样式的优先级最高</h1>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


2. 写一个盒子模型的简单案例,体会padding/border的简写规则

实例

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>盒子模型的简单案例,padding/border的简写规则</title>
    <style>
        #first{
            width:200px;
            height: 300px;
            border: 2px solid black;
        }
        #first p{
            width: 80%;
            height: 40%;
            border: 2px solid red;
            text-align: center;
            line-height: 120px;
            margin: 16px;
        }
    </style>
</head>
<body>
<div id="first">
    <p>第一个段落的内容</p>
    <p>第二个段落的内容</p>
</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post