CSS入门
-
style
元素设置CSS -
基本格式
<style type="text/css">
body { background-color: #eaf3da; }
p {
border: 1px solid gray;
}
</style> -
给多个元素同一个css,加
,
h1,h2{ }
-
继承与覆盖继承
-
link
加载css文件<link rel="stylesheet" type="text/css" href="lounge.css" rel="external nofollow" >
type能被省略 -
class
为所有class指定css<p class="greetea">
CSS:
p.greetea{
color: green;
}如果所有greetea都要用的话:
.greetea{
color: green;
} -
一个元素能指定多个
class
<p class="greentea respberry blueberry">
当CSS发生冲突时,会选择最后一个
-
验证CSS
http://jigsaw.w3.org/css-validator/
基本属性
可以在这个网站查询常用的颜色名,或使用RGB
-
backgroud-color
背景颜色 -
font-family
字体,可以用中文直接用宋体,黑体都行
-
top
控制元素顶部位置 -
text-align
左对齐 居中 右对齐 -
letter-spacing
字母间设置间距 -
font-weight
字体宽细 -
border
边框 -
font-style
设置斜体 -
left
元素左边位置 -
padding
内边距 -
list-style
列表外观 -
line-height
行间距 -
font-size
字体大小 -
background-image
背景图像