CSS中關於層疊與繼承的圖文介紹

來源:互聯網
上載者:User

三種繼承css方式

1.段內繼承

<pstyle="color: red;font-size:50px;">樣式原文</p>

  1. 原文變成 紅色,

  2. 原文字型變大

兩個都是通過改變樣式屬性的值去實現的. 文法詳解:

1.每個樣式屬性會有不同的值, "color: red" 通過冒號表達color的屬性.

2.屬性間要用分號間隔和閉合

3.font-size 屬於複合屬性

2. 文檔內繼承

<style> 全域style 要使用<style>標籤, 設定在< head>頭部之間

style – type 聲明css的作用類型

p{ 樣式屬性} p是範圍, 也可以是 <table><input> 等等的其他標籤, p只不過是一個例子

文檔內繼承會比段內繼承的優先順序低, 優先執行段內的,所以 同時<p>的樣式, 第一個原文執行了全域style, 第二個執行了段內style

  1. 文檔外繼承

    1. 作用檔案 引用 css檔案樣式

    2. 需要先建立一個額外的尾碼名為css檔案

    3. 編輯檔案,建立css 樣式

相關文章

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.