css基本語法及頁面引用
阿新 • • 發佈:2017-12-17
式表 pre class 創建 pos width 樣式 tex type
css基本語法
css的定義方法是:
選擇器 { 屬性:值; 屬性:值; 屬性:值;}
選擇器是將樣式和頁面元素關聯起來的名稱,屬性是希望設置的樣式屬性每個屬性有一個或多個值。代碼示例:
div{ width:100px; height:100px; color:red }
css頁面引入方法:
1、外聯式:通過link標簽,鏈接到外部樣式表到頁面中。
<link rel="stylesheet" type="text/css" href="css/main.css">
2、嵌入式:通過style標簽,在網頁上創建嵌入的樣式表。
<style type="text/css"> div{ width:100px; height:100px; color:red } ...... </style>
3、內聯式:通過標簽的style屬性,在標簽上直接寫樣式。
<div style="width:100px; height:100px; color:red ">......</div>
css基本語法及頁面引用