CSS动画属性性能

1321次阅读  |  发布于5年以前

CSS动画属性性能

div {
  -webkit-animation-duration: 5s;
  -webkit-animation-name: move;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-direction: alternate;
  width: 200px;
  height: 200px;
  margin: 100px;
  background-color: #808080;
  position: absolute;
}
@-webkit-keyframes move{
    from {
        left: 100px;
    }
    to {
        left: 200px;
    }
}

如下图使用left将持续触发页面重绘,表现为红色边框:

move

@-webkit-keyframes move{
    from {
        -webkit-transform: translateX(100px);
    }
    to {
        -webkit-transform: translateX(200px);
    }
}

如下图使用-webkit-transform页面只发生重组,表现为橙色边框:

move2

CSS Property Animation on the Web

参考

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8