zoukankan      html  css  js  c++  java
  • css 引入的 方式有哪些? link与post有什么区别??

    有四钟形式:

    1.链入外部样式表,就是把样式表保存为一个样式表文件,然后在页面中用<link rel="stylesheet" type="text/css" href="css文件的路径.css">连接这个样式表文件。

    2.内部样式表,就是把样式表方在页面的head区里

    <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">
        <title>Document</title>
        <style type="text/css">//这种方式写css样式
        div{
             100px;
        }
        </style>
    </head>
    

    3.导入外部样式表,用@import,在<head>与</head>之间,

    <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">
        <title>Document</title>
       <style>
       @import"*.css"  //css文件存放的路径
       </style>
    </head>
    

    4.内嵌样式,就是在标签内写入style=" ",比如:

    <body>
        <div style=" 100px;height: 100px;"></div> //直接写到标签中 
    </body>  

    这几种方式的区别 

    1.link是XHTML标签,除了加载css外,还可以定义RSS等其他事务;@import属于css范畴,只能加载css。

    2.link加载css样式时,在页面加载时同时加载;@import需要页面完全加载完以后才会加载;

    3.link是XHTML标签,无兼容问题;@import是在css2.1提出的,低版本的浏览器不支持;

    4.link支持使用javascript控制DOM去改变样式;而@import不支持。 

     

  • 相关阅读:
    Linux修改环境变量的方法
    读书笔记:高性能网站建设
    xtrabackup备份还原
    自制mysql.rpm安装包
    python装饰器
    python中闭包
    python中返回函数
    python中自定义排序函数
    python中filter()函数
    python中reduce()函数
  • 原文地址:https://www.cnblogs.com/ting0410/p/10546905.html
Copyright © 2011-2022 走看看