• css的四种引入方式


    css概述:

    CSS是Cascading Style Sheets的简称,中文称为层叠样式表,用来控制网页数据的表现,可以使网页的表现与数据内容分离。

    css的四种引入方式:

    1.行内式
              行内式是在标记的style属性中设定CSS样式。这种方式没有体现出CSS的优势,不推荐使用

    <div style="color: deeppink; background-color: greenyellow">hello man</div>

    2.嵌入式
              嵌入式是将CSS样式集中写在网页的<head></head>标签对的<style></style>标签对中

    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
        <style>
            p{
                color:deeppink;
                font-size: 20px;
                background-color: yellowgreen;
            }
            a{
                text-decoration: none;
            }
        </style>
    </head>

    3 链接式
                将一个.css文件引入到HTML文件中

    <link rel="stylesheet" href="day102.css">

    4.导入式
              将一个独立的.css文件引入HTML文件中,导入式使用CSS规则引入外部CSS文件,<style>标记也是写在<head>标记中

    <style>
        @import "day102.css";
    </style>

    注意:

          导入式会在整个网页装载完后再装载CSS文件,因此这就导致了一个问题,如果网页比较大则会出现先显示无样式的页面,闪烁一下之后,再出现网页的样式。这是导入式固有的一个缺陷。使用链接式时与导入式不同的是它会以网页文件主体装载前装载CSS文件,因此显示出来的网页从一开始就是带样式的效果的,它不会象导入式那样先显示无样式的网页,然后再显示有样式的网页,这是链接式的优点。

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="keywords" content="css的四种引入方式">
        <meta name="description" content="study">
        <meta http-equiv="Refresh" content="60;https://www.baidu.com">
        <meta http-equiv="x-ua-compatible" content="IE=EmulateIE7">
        <title>Title</title>
    
        <style>
            /*p{*/
            /*    color:deeppink;*/
            /*    font-size: 20px;*/
            /*    background-color: yellowgreen;*/
            /*}*/
            /*a{*/
            /*    text-decoration: none;*/
            /*}*/
        </style>
        <!--第二种css引入方式(嵌入式):style标签通过css代码所写标签名字来找-->
    
        <!--<link rel="stylesheet" href="day102.css">-->
        <!--第三种css引入方式(链接式),通过引入css文件,css文件直接写css代码就可以了;通过html语言规范引用过来,属于html范畴;link引入次数不限,可引入多个文件;先准备css,准备好后再加载html-->
    
        <style>
            @import "day102.css";
        </style>
        <!--第四种css引入方式(导入式),通过css规范引用过来的;导入式文件数量有限制;先加载html后加载css,所以有时候看到有些html没有被css渲染-->
    
    </head>
    <body>
    
        <!--<div style="color: deeppink; background-color: greenyellow">hello man</div>-->
        <!--style属性值就是css代码,css代码规范就是一组组键值对;这是第一种css引入方式(行内式),以后尽量不要这么使用-->
    
        <span>hello span</span><br>
        <a href="https://www.baidu.com" target="_blank">我可以点击</a>
        <p>hello p</p>
        <p>hello p2</p>
    
    </body>
    </html>
    p{
        color:greenyellow;
        background-color: red;
    }
    
    a{
        text-decoration: none;
    }

    css文件里的代码,直接写css代码即可

    while True: print('studying...')
  • 相关阅读:
    一般操作
    node express mongodb 数据录入
    express新版本后app.use(express.bodyParser())无效
    npm adduser报错问题
    01demo-mongodb
    Win32汇编--02必须了解的基础知识
    第17章 本书最后将学习什么呢(需要回头学习)
    第十六章 直接定址表(需要回头学)
    指令系统总结
    第十五章 外中断
  • 原文地址:https://www.cnblogs.com/xuewei95/p/14923795.html
Copyright © 2020-2023  润新知