Js点击触发Css3的动画Animations、过渡Transitions效果关键是⾸先指定动画效果的CSS属性名称,然后在Js中改变这个属性
如果不使⽤Js触发,可以选择利⽤css的状态:hover,focus,active 来触发,也可以⼀开始就触发
下例为Js点击触发过渡Transitions效果,指定的属性名称是width
js文字动画特效
<!DOCTYPE html>
<html>
<head>
<style>
#aaa {
width: 100px;
height: 100px;
background: blue;
transition: width 2s;
-moz-transition: width 2s; /* Firefox 4 */
-webkit-transition: width 2s; /* Safari and Chrome */
-o-transition: width 2s; /* Opera */
}
</style>
<script>
function big() {
}
function small() {
}
</script>
</head>
<body>
<button onclick="big()">Big</button>
<button onclick="small()">Small</button>
<div id="aaa"></div>
</body>
</html>
原创⽂章,欢迎转载,转载请注明出处!