河南新华专注互联网教育三十二年 到校参观路费报销 免费试听课程!
一、新增的选择器
CSS3新增的属性选择器 {除ie6外的大部分浏览器支持)
1E[att^="val"]属性att的值以"val"开头的元素div[id^="nav"] { background:#ff0; }
2E[att$="val"皮升]属性att的值以"val"结尾的元素
3E[att*="val"]属性att的值包含"val"字符串的元素
结构伪类选择器(过滤选择器)
(注:FireFox 1.5/2.0/3.0支持E:root,FireFox 3.0支持E:last-child、E:only-child、E:empty。燃孙老
由于IE6/7/8不支持,没办法,选择合适的场合用吧。)
4E:root匹配文档的根元素,对于HTML文档,就是HTML元素
5E:nth-child(n)匹配其父元素的第n个子元素,第一个编号为1p:nth-child(3) { color:#f00; }
6E:nth-last-child(n)匹配其父元素的倒数第n个子元素,第一个编号为1p:last-child { background:#ff0; }
7E:nth-of-type(n)与:nth-child()作用类似,但是仅匹配使用同种标签的元素p:nth-of-type(2){color:red;}选择父元素的第n个子元素p
8E:nth-last-of-type(n)与:nth-last-child() 作用类似,但是仅匹配使用同种标签的元素
9E:last-child匹配父元素的最后一个子元素,凯亮等同于:nth-last-child(1)
10E:first-of-type匹配父元素下使用同种标签的第一个子元素,等同于:nth-of-type(1)
11E:last-of-type匹配父元素下使用同种标签的最后一个子元素,等同于:nth-last-of-type(1)
12E:only-child匹配父元素下仅有的一个子元素,等同于:first-child:last-child或 :nth-child(1):nth-last-child(1)p:only-child { background:#ff0; }
13E:only-of-type匹配父元素下使用同种标签的唯一一个子元素,等同于:first-of-type:last-of-type或 :nth-of-type(1):nth-last-of-type(1)
14E:empty匹配一个不包含任何子元素的元素,注意,文本节点也被看作子元素p:empty { background:#ff0; }
与用户界面(UI)有关的伪类(ie6 7 8不支持)
15E:enabled匹配表单中激活的元素
16E:disabled匹配表单中禁用的元素input[type="text"]:disabled { background:#ddd; }
17E:checked匹配表单中被选中的radio(单选框)或checkbox(复选框)元素
18E::selection匹配用户当前选中的元素
级元素通用选择器
ie6不支持
19E ~ F匹配任何在E元素之后的同级F元素p ~ ul { background:#ff0; }
反选伪类
(ie6 7 8 firefox3.0以下 Opera9.0不支持)
20E:not(s)匹配不符合当前选择器的任何元素:not(p) { border:1px solid #ccc; }
:target 伪类
(ie6 7 8不支持)
二、css3新增属性
一. box-shadow(阴影效果)
使用:
box-shadow: 20px 10px 0 #000;
-moz-box-shadow: 20px 10px 0 #000;
-webkit-box-shadow: 20px 10px 0 #000;
支持:
FF3.5, Safari 4, Chrome 3
二. border-colors(为边框设置多种颜色)
border: 10px solid #000;
-moz-border-bottom-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;
-moz-border-top-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;
-moz-border-left-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;
-moz-border-right-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;
说明:
颜色值数量不固定, 且FF的私有写法不支持缩写: -moz-border-colors: #333 #444 #555;
FF3◆
三. boder-image(图片边框)
-moz-border-image: url(exam.png) 20 20 20 20 repeat;
-webkit-border-image: url(exam.png) 20 20 20 20 repeat;
边框的宽度, 分别对应top, right, bottom, left边框, 改变宽度可以实现不同的效果;
(2). 边框图片效果(目前仅实现了两种):
repeat --- 边框图片会平铺, 类似于背景重复;
stretch --- 边框图片会以拉伸的方式来铺满整个边框;
(3). 必须将元素的边框厚度设置为非0非auto值.
FF 3.5, Safari 4, Chrome 3
四. text-shadow(文本阴影)
text-shadow: [] || [];
(1) 和是可选的, 当未指定时, 将使用文本颜色; 当未指定时, 半径值为0;
(2) shadow可以是逗号分隔的列表, 如:
text-shadow: 2px 2px 2px #ccc, 3px 3px 3px #ddd;
(3) 阴影效果会按照shadow list中指定的顺序应用到元素上;
(4) 这些阴影效果有可能相互重叠, 但不会叠加文本本身;
(5) 阴影可能会跑到容器的边界之外, 但不会影响容器的大小.
FF 3.5, Opera 10, Safari 4, Chrome 3
五. text-overflow(文本截断)
text-overflow: inherit | ellipsis | clip ;
-o-text-overflow: inherit | ellipsis | clip;
(1) 还有一个属性ellipsis-word, 但各浏览器均不支持.
IE6◆, Safari4, Chrome3, Opera10
六. word-wrap(自动换行)
word-wrap: normal | break-word;
IE6◆, FF 3.5, Safari 4, Chrome 3
七. border-radius(圆角边框)
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
FF 3◆, Safari 4 , Chrome 3
八. opacity(不透明度)
opacity: 0.5;
filter: alpha(opacity=50); /* for IE6, 7 */
-ms-filter(opacity=50); /* for IE8 */
all
九. box-sizing(控制盒模型的组成模式)
box-sizing: content-box | border-box; // for opera
-moz-box-sizing: content-box | border-box;
-webkit-box-sizing: content-box | border-box;
1. content-box:
使用此值时, 盒模型的组成模式是, 元素宽度 = content ◆ padding ◆ border;
2. border-box:
使用此值时, 盒模型的组成模式是, 元素宽度 = content(即使设置了padding和border, 元素的宽度
也不会变).
FF3◆, Opera 10, Safari 4, Chrome 3
十. resize(元素缩放)
resize: none | both | horizontal | vertical;
1. 必须将元素的overflow属性设置为auto或hidden, 该属性才能起作用(overflow设置为visible时, 无效);
2. 属性值说明:
禁用缩放;
可同时缩放宽度和高度;
仅能缩放宽度;
仅能缩放高度;
safari 4, chrome 3
十一. outline(外边框)
outline: 边框厚度 边框样式 边框颜色;
outline-offset: 偏移值;
outline-offset需要独立写, 简写是无效的.
FF3◆, safari 4, chrome 3, opera 10
十二. background-size(指定背景图片的尺寸)
-o-background-size: [length | percentage] {1, 2};
-webkit-background-size: [length | percentage] {1, 2};
例如:
-o-background-size: 50px 60px;
-webkit-background-size: 50px 60px;
这会将背景图片的宽设置了50px, 高60px.
safari 4, chrome 3, opera 10
十三. background-origin(指定背景图片从哪里开始显示)
-webkit-background-origin: border | padding | content;
-moz-background-origin: border | padding | content;
从border区域开始显示背景;
从padding区域开始显示背景;
从content区域开始显示背景;
注意:
1. 必须先指定background属性, 然后才能指定该属性, 如果该属性出现在background属性之前,
会无效.
safari 4, chrome 3, FF 3◆
十四. background-clip(指定背景图片从什么位置开始裁切)
-webkit-background-origin: border-box | padding-box | content-box | no-clip;
从border区域向外裁剪背景;
从padding区域向外裁剪背景;
从content区域向外裁剪背景;
不裁切背景.
十五. background(为一个元素指定多个背景)
background: [background-image] | [background-origin] | [background-clip] | [background-repeat] | [background-size] | [background-position]
例子:
background: url(bg1.png) no-repeat left top, url(bg2.png) no-repeat right bottom;
十六. hsl(通过色调, 饱和度, 亮度来指定颜色值)
hsl: ( ||
||
);
(1) length: h(色调), 0(或360)表示红色, 120表示绿色, 240表示蓝色;
(2) percentage: s(饱和度), 取值为0%到100%之间的值;
(3) percentage: l(亮度), 取值为0%到100%之间的值;
background: hsl(240, 50%, 100%);
color: hsl(100, 80, 100%);
safari 4, chrome 3, FF3, opera 10
十七. hsla(在hsl的基础上上增加了一个透明度设置)
hsla: ( ||
|| );
(1) opacity: a(透明度), 取值在0到1之间;
background: hsl(240, 50%, 100%, 0.5);
color: hsl(240, 50%, 100%, 0.5);
十八. rgba(基于r,g,b三个颜色通道来设置颜色值, 通过a来设置透明度)
rgba: (r, g, b, opacity);
(1) r: 红色, 正整数 | 百分数;
(2) g: 绿色, 正整数 | 百分数;
(3) b: 蓝色, 正整数 | 百分数;
(4) a: 透明度, 取值在0到1之间;
(5) 正整数在0到255之间, 百分数在0%到100%之间.
rgba: (100%, 244, 0, 0.5);
十九、 transition(a标签hover渐隐效果)
a:hover{transition: color 0.15s linear 0s, background-color 0.3s linear 0s;}
-webkit-transition:color 0.15s linear 0s, background-color 0.3s linear 0s;
-moz-transition:color 0.15s linear 0s, background-color 0.3s linear 0s;
-o-transition:color 0.15s linear 0s, background-color 0.3s linear 0s;
-ms-transition:color 0.15s linear 0s, background-color 0.3s linear 0s;
transition:color 0.15s linear 0s, background-color 0.3s linear 0s;
CSS3新特性
1. animation:动画
2. transition:动画速度
3. transform:变形
4. 伪元素
5. 边框
border-radius 圆角边框
box-shadow 盒子阴影
border-image 边框背景123
背景
background-size 背景搏咐握大小
background-origin 背景的起始点
background-clip 背景的覆基庆盖范围
background-image 设置背景图片1234
文本
text-shadow 文本阴简碰影
text-wrap 文本换行
@font-face 设置字体
有好多啊 原来要javascript实现的复杂代码才能实现
比如 文本类型
以上就是土嘎嘎小编大虾米为大家整理的css3新增的背景属性有哪些?_属于css3新增的属性有相关主题介绍,如果您觉得小编更新的文章对您有所帮助,不要忘记讲本站分享给您身边的朋友哦!!