---
title: "css基础"
author: "yunchow"
date: "2009-09-20T23:25:58Z"
tags: ["CSS"]
categories: ["非技术"]
slug: "css"
draft: false
lastmod: "2009-09-21T00:20:35Z"
id: 472798
url: "https://yunchow.iteye.com/blog/472798"
---

========= CSS 基础 ======== css - 空格大小写敏感 ----------------------------- class, id对大小写是敏感的 CSS - 派生选择器 li strong { font-style: italic; font-weitht: normal; } //只有li下的strong标签才会采用这种格式。 ----------------------------------- ID选择器（应用的最广泛） #red {color: red;}

//大小写必需完全一样

可以与ID选择器互换 .classname{...}//可以在任意地方使用。 ---------------------------- 伪类选择器 a:link {color:#ff0000} a:visited {color: #00ff00} a:hover {color:..} a:active {...} ------------------------ * 复合选择器的优先级计算(重要) ID选择器(100) &gt; 类选择器(10) &gt; 标记选择器(1) #h1 {color:red} .h1 {...} h1 {...}

# ------------------------ 复杂选择器名称的分解 #menu a.class:hover b, .special b.class{...} [**a.class 表示 class里面的a ----------------------------------- 行内样式: 建议不常用** \ **内嵌式： 不能共享 链接式： 应用最广 导入式 -------------------------------------- CSS 背景 p {background-color: gray;} 可以为所有元素设置背景色，不继承 不指定则为：trasparent，透明的 body {background-image: url(/i/1.gif);} ---------------------------------------- CSS 的盒子模型 如图片：盒子模型.bmp CSS 外边距合并，只有上下才合，左右不合 盒子模型的特性： 边界值margin可为负 边框border.... 边框是实的，而填充和边界是虚的。 盒子模型只能设置边枉颜色和背景 大部分盒子模型默认值为0。 ---------------------------------------**]()