四種引入css的方式總結

來源:互聯網
上載者:User
本文主要為大家分享一篇引入css的四種方式總結,具有很好的參考價值,希望對大家有所協助。一起跟隨小編過來看看吧,希望能協助到大家。

1.內聯式引用:直接用在標籤上,但維護成本高

style='font-size:16px;color:#000000'

2.外部串連式引用:css代碼與html代碼分離,便於代碼重複使用

<link href="css/style.css" type="text/css" rel="stylesheet" />

style.css檔案內容如右:

.font{color:blue;font-size:12px;}

3.內部式引用:頁面較為清晰,但不能被別的頁面使用

<style type='text/css'>    .font{color:blue;font-size:12px;}</style>

4.外部匯入式:可以在一個HTML檔案中匯入多個樣式表。類似於外部連結式引用

在HTML檔案中head標籤中加入

<style type='text/css'>    @import url('./style/style.css');</style>

大家學會了嗎?覺得有用的趕緊收藏起來吧。

相關文章

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.