CSS
1、div标签
容器标签
2、语法
<style type="text/css">
选择器{属性 属性值;}
</style>
3、选择器
标签选择器 p
类选择器 .class
id选择器 #id
多个同时选择(且),各个标签用,分割
4、CSS控制方法
1、行内样式:在标签中直接用style属性控制
2、内嵌样式:在<head>中用<style>声明
3、外部样式:<link>引用
@import url("CSS路径")导入
5、主要属性
1、字体属性
font-size 字体大小
font-family 字体类型,可设置多个用,隔开;有汉字或者空格需""包裹
font-style 字体风格,斜体 normal-正常;italic-斜体;oblique倾斜体
font-weight 字体粗细,bold粗体,normal正常,数字
font 依次设置以上各属性,用,隔开
2、文本属性
color 文本颜色 直接设置或RGB颜色
line-height 行高 px,x%,数字。
text-align 文本对齐方式
text-decoration 添加修饰 上下(overline、underline)划线
3、列表属性
list-style-type 列表类型 *disc 黑园点,circle空心,square黑方框,none无标识
list-style-image 表象图像 url(...)
list-style-position 列表位置 outside 列表项目不在文本内
inside 列表项目不在文本内
list-style 依次设置以上各属性,用,隔开
4、浮动属性
关于浮动:浮动的框可以向左或向右移动,直到它的外边缘碰到包含框或另一个浮动框的边框为止。
由于浮动框不在文档的普通流中,所以文档的普通流中的块框表现得就像浮动框不存在一样。
float 浮动方向 left,right,*none
clear 不允许浮动方向 left,right,*none,both
5、大小属性
width
height
6、背景属性
backgroud-color 颜色 同color属性,其中用transparent表示透明
backgroud-image 图像 url(...)
backgroud-repeat 重复方式 repeat另个方向 repeat-x水平 repeat-y垂直 no-repeat均不重复
backgroud-position 图像起始位置 XXpx,XXpx
7、盒子模型(位置属性)
border 边框
padding 填充 ---内边距
margin 边界 ---外边距
content 内容
实际宽度为以上四个之和
border
top,left,right,bottom四个
color 颜色
width 宽度
style 样式 none-无;dotted-点状线(实线);dashed-虚线;solid-实线;double-双线
border 依次设置以上个属性
padding
top,left,right,bottom四个
margin
top,left,right,bottom四个
8、定位
position --定位 static,absolute绝对,relative相对,fixed绝对·
float --浮动
z-index --空间位置
position
和top、right、bottom、left与absolute,relative连用表示
元素边界离页面边框或原来位置的距离
absolute绝对用于随滚动条滚动的特效
其定位相对于第一个
relative相对
z-index 各个块的堆叠顺序(Z轴位置)
属性值由大到小,位置由下而上
9、CSS样式处理
对超级链接
a:link 未访问连接
a:visited 已访问连接
a:hover 移动到连接上
a:active 选中激活连接
[注]a:hover在a:link、a:visited之前才有效
a:active在a:hover之后采有效
对鼠标
cursor控制鼠标,改变鼠标效果
cursor:pointer; 手状
cursor:help; 带问号
cursor:move; 移动
显示隐藏
display:none 隐藏
display:block 显示