CSS的四種引入方式

來源:互聯網
上載者:User

標籤:sse   ext   mil   order   back   href   動畫   top   type   

1.使用link標籤引入css檔案:
<head>    <link rel="stylesheet" type="text/css" href="assets/css/index.css"></head>
2.使用style標籤:
<head>  <style>    #info-bar{      background-color: #23499E;      /* 設定大小為0,從而實現從小到大的動畫 */      opacity: 0;      height: 0px;      width: 0px;      padding: 0px;      border-radius: 50%;      /* 設定字型 */      color: #31DE9F;      font-weight: bold;      font-size: 30pt;      /* 定位在@+的上方,隱藏超出部分 */      position: fixed;      left: 50%;      top: 68%;      transition: All 0.6s ease-in-out;    }  </style></head>

style標籤可以出現在html的任何位置,但是一般寫在head標籤內。

3.使用標籤的style屬性:
<div id="container" style="font-family: Arial, sans-serif;text-align: center;"></div>

 

4.使用@import引入css檔案:

1)放在html的style標籤內:

<style>    @import url(style.css);</style>

2)放在css檔案中:

@import "style.css";

 

四者之間的比較:

要做到關注點分離盡量用第一種和第四種,但是第一種目前更常用。

CSS的四種引入方式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.