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不支持。 

     

  • 相关阅读:
    UVA 1386 Cellular Automaton
    ZOJ 3331 Process the Tasks
    CodeForces 650B Image Preview
    CodeForces 650A Watchmen
    CodeForces 651B Beautiful Paintings
    CodeForces 651A Joysticks
    HUST 1601 Shepherd
    HUST 1602 Substring
    HUST 1600 Lucky Numbers
    POJ 3991 Seinfeld
  • 原文地址:https://www.cnblogs.com/ting0410/p/10546905.html
Copyright © 2011-2022 走看看