伪类选择器
a:link { // 访问前状态
color: #333;
}
a:visited { // 访问后状态
color: #0f0;
}
a:hover { // 鼠标悬浮状态
color: #f00;
}
a:active { // 鼠标点击状态
color: #00f;
}
背景属性
背景颜色
background-color
背景图片
background-color: url(xxx.jpg)
背景重复
background-repeat
● repeat 重复
● no-repeat 不重复
● repeat--x 水平重复
● repeat--y 垂直重复
背景定位
background-position
- 单词表示法:
属性值有两个:第一个 水平方向的位置,另一个是垂直方向的位置
a. left center right
b. top center bottom - 像素表示法
第一个像素值表示距离左边距的距离,另一个是表示距离顶点的距离【分正负】
a. 100px,20px - 百分比表示法
背景附着
background-attachment
● scroll 滚动的
● fixed 固定的
CSS3 新增背景属性
背景半透明
颜色新增了一种 rgba 模式
语法:rgba(红色,绿色, 蓝色,不透明度)
背景缩放
background-size
● px值
● 百分比
● cover 自动缩放比例,把背景图像调整成足够大
● contain 自动缩放比例,把背景图像调整成最大
多背景
CSS3中,一个盒子中,可以添加多个背景
定位属性
position
● relative 相对定位
● absolute 绝对定位
● fixed 固定定位
相对定位
relative,必须搭配偏移量属性才能发生位置移动
.box {
position: relative;
left: -100px;
top: -100px;
background: yellowgreen;
}