css的三大特性(继承,层叠,优先级)

一,继承


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>24-css三大特性之继承性.htmltitle>
    <style>
        div{
            color: red;
            font-size:30px;
            /*background: green;*/
            text-decoration: none;
        }
    style>
head>
<body>

<div>
    <p>我是段落p>
div>
<div>
    <ul>
        <li>
            <p>我是段落p>
        li>
    ul>
div>
<div>
    <a href="#">我是超链接a>
div>
<div>
    <h1>我是标题h1>
div>
body>
html>

二,层叠性


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>25-css三大特性之层叠性.htmltitle>
    <style>
        p{
            color: red;
        }
        .para{
            color: aqua;
        }
    style>
head>
<body>

<p id="identity" class="para">我是段落p>
body>
html>

三,优先级


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>26-css三大特性之优先级.htmltitle>
    <style>
        #id1{
            color: blue;
        }
        .para{
            color: red;
        }
    style>
head>
<body>

body>

<ul>
    <li>
        <p id="id1" class="para">我是段落p>
    li>
ul>
html>

四,提升优先级


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>27-css优先级之importent.htmltitle>
    <style>
        #id1{
            color: blue;
        }
        .para{
            color: red !important;
        }
        *{
            color: aqua;
        }
    style>
head>
<body>

<ul>
    <li>
        <p id="id1" class="para">我是段落p>
    li>
ul>
body>
html>

五,权重计算


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>28-css优先级之权重.htmltitle>
    <style>
        #identity1 .box2{
            color: red;
        }
        .box1 .box2{
            color: aqua;
        }
        div ul li p{
            color: green;
        }
    style>
head>
<body>

<div id="identity1" class="box1">
    <ul>
        <li>
            <p id="identity2" class="box2">我是段落p>
        li>
    ul>
div>
body>
html>

你可能感兴趣的:(前端基础语言从学习)