CSS
CSS 指层叠样式表 (Cascading Style Sheets)
CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明。
h1 {color:red; font-size:14px;} h1为选择器,color:red为声明,color为属性,red为值,多个声明用分号;隔开
派生选择器 li strong { font-style: italic; font-weight: normal; } 只有li 元素中的 strong 元素的样式为斜体字
id选择器以"#"来定义 #red {color:red;} 这个段落是红色。
类选择器以"."为开头 .center {text-align: center} This heading will be center-aligned
属性选择器 [title] { color:red; } 属性和值选择器 [title=W3School] { border:5px solid blue; } 指定值的 title 属性的所有元素设置样式 [title~=hello] { color:red; }
插入样式表
外部样式表
内部样式表 使用
内联样式 This is a paragraph
背景色 p {background-color: gray;}
背景图像 body {background-image: url(/i/eg_bg_04.gif);}
背景定位 background-position:center;