CSS3总结「2」

Posted by Chen on February 13, 2021

1.CSS3 过渡

CSS3 过渡是元素从一种样式逐渐改变为另一种的效果。

要实现这一点,必须规定两项内容:

1
2
规定您希望把效果添加到哪个 CSS 属性上
规定效果的时长
过渡属性

下面的表格列出了所有的转换属性:

1
2
3
4
5
6
   属性	                          描述	                          
transiti           简写属性用于在一个属性中设置四个过渡属性
transition-property	    规定应用过渡的 CSS 属性的名称
transition-duration	    定义过渡效果花费的时间默认是 0。	
transition-timing-function	   规定过渡效果的时间曲线默认是 "ease"
transition-delay	   规定过渡效果何时开始默认是 0。

2.CSS3 动画

改变背景色和位置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  <!DOCTYPE html>
  <html>
<head>
<style> 
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:myfirst 5s;
-moz-animation:myfirst 5s; /* Firefox */
-webkit-animation:myfirst 5s; /* Safari and Chrome */
-o-animation:myfirst 5s; /* Opera */
}
@keyframes myfirst
{
0%   {background:red; left:0px; top:0px;}
25%  {background:yellow; left:200px; top:0px;}
50%  {background:blue; left:200px; top:200px;}
75%  {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
@-moz-keyframes myfirst /* Firefox */
{
0%   {background:red; left:0px; top:0px;}
25%  {background:yellow; left:200px; top:0px;}
50%  {background:blue; left:200px; top:200px;}
75%  {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
0%   {background:red; left:0px; top:0px;}
25%  {background:yellow; left:200px; top:0px;}
50%  {background:blue; left:200px; top:200px;}
75%  {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
@-o-keyframes myfirst /* Opera */
{
0%   {background:red; left:0px; top:0px;}
25%  {background:yellow; left:200px; top:0px;}
50%  {background:blue; left:200px; top:200px;}
75%  {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
</style>
</head>
<body>
<p><b>注释</b>本例在 Internet Explorer 中无效</p>
<div></div>
</body>
</html>
CSS3 动画属性

下面的表格列出了 @keyframes 规则和所有动画属性:

1
2
3
4
5
6
7
8
9
10
11
    属性	                    描述	
@keyframes	               规定动画	
animation           	所有动画属性的简写属性除了 animation-play-state 属性	
animation-name	        规定 @keyframes 动画的名称	
animation-duration	    规定动画完成一个周期所花费的秒或毫秒默认是 0	
animation-timing-function	规定动画的速度曲线默认是 "ease"	
animation-delay	          规定动画何时开始默认是 0	
animation-iteration-count    	规定动画被播放的次数默认是 1	
animation-direction	        规定动画是否在下一周期逆向地播放默认是 "normal"	
animation-play-state	    规定动画是否正在运行或暂停默认是 "running"	
animation-fill-mode	       规定对象动画时间之外的状态

3.CSS3 多列

1
2
3
column-count 属性规定元素应该被分隔的列数
  column-gap 属性规定列之间的间隔
   column-rule 属性设置列之间的宽度样式和颜色规则

4.CSS3 用户界面

1
2
3
resize 属性规定是否可由用户调整元素尺寸
box-sizing 属性允许您以确切的方式定义适应某个区域的具体内容
outline-offset 属性对轮廓进行偏移并在超出边框边缘的位置绘制轮廓


  相关文章:

「Disqus用户留言」:



「游客用户留言」: