星空网 > 软件开发 > 网页设计

CSS3动画中的位置设定问题

水平居中的不同方法实现:

 position: absolute; margin:0 auto; left:0; right:0;

position: absolute; left:50%; -webkit-transform:translateX(-50%);

 

垂直居中的几种实现方法:

 position: absolute; margin:auto 0; top:0; bottom:0;

position: absolute;top:50%;-webkit-transform:translateY(-50%);

中心居中的几种方法:

position: absolute;margin:auto;top:0;bottom:0;left:0;right:0;

 position: absolute; top:50%; left:50%; -webkit-transform:translateX(-50%) translateY(-50%);

透明度的控制(渐显效果)

@-webkit-keyframes opacity_kf {      0% {        opacity: 0;      }      100% {        opacity: 1;      }     }


延时效果的控制:

当使用@keyframes创建动画时,一定要把它捆绑到某个选择器,否则不会产生动画。另外必须定义动画的名称和时长,如果忽略时长,那么动画不允许,因为默认值是0。如果是几个动画延时出现构成的整体动画,那么可以为每个小动画设置不同延时,令他们相继出现,当为一个对象设置不同时间的不同状态时最好使用百分比来规定变化发生的时间,或用关键词“from”“to”等同于0%和100%(分别为动画的开始和结束)。

代码示例如下:

div{animation: myfirst 5s;-moz-animation: myfirst 5s;  /* Firefox */-webkit-animation: myfirst 5s;  /* Safari 和 Chrome */-o-animation: myfirst 5s;  /* Opera */}

@keyframes myfirst{0%  {background: red;}25% {background: yellow;}50% {background: blue;}100% {background: green;}}@-moz-keyframes myfirst /* Firefox */{0%  {background: red;}25% {background: yellow;}50% {background: blue;}100% {background: green;}}@-webkit-keyframes myfirst /* Safari 和 Chrome */{0%  {background: red;}25% {background: yellow;}50% {background: blue;}100% {background: green;}}@-o-keyframes myfirst /* Opera */{0%  {background: red;}25% {background: yellow;}50% {background: blue;}100% {background: green;}}

@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 和 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;}}

CSS3动画中的位置设定问题




原标题:CSS3动画中的位置设定问题

关键词:CSS

CSS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

凭技术做外贸:关键词优化的高效工具推荐:https://www.ikjzd.com/articles/94395
宝藏丝路:“一带一路”强力助攻我国贸易增长!:https://www.ikjzd.com/articles/94397
图文实操:​如何监测竞争对手的Facebook广告?(上):https://www.ikjzd.com/articles/94399
巨大流量和爆款机会别流失!俚语词不容小觑!:https://www.ikjzd.com/articles/94400
贸易战升级,亚洲至美国航线即期运价持续下跌!:https://www.ikjzd.com/articles/94402
货真价实!奉上国际站新手快速出单秘籍一份!:https://www.ikjzd.com/articles/94403
皇家游轮航线 皇家邮轮旅游攻略:https://www.vstour.cn/a/408245.html
2017春节旅游攻略有吗:https://www.vstour.cn/a/408246.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流