单击事件触发型:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<style>
.arrowTransform {
transition: 0.2s;
transform-origin: center;
transform: rotateZ(180deg);
}
.arrowTransformReturn {
transition: 0.2s;
transform-origin: center;
transform: rotateZ(0deg);
}
</style>
<body>
<div id="app"><img :class="{ 'arrowTransform': !flag, 'arrowTransformReturn': flag}" src="1.png" alt=""
@click="flag = !flag"></div>
<script>
const app = new Vue({
el: "#app",
data: {
flag: false
}
})
</script>
</body>
</html>
hover型:利用字体图标结合动画
CSS的rotate只 对block或 inline-block类型元素有效
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<link rel="stylesheet" href="http://at.alicdn.com/t/font_3231229_sv4mc3i24fh.css">
</head>
<style>
span {
display: inline-block;
}
.more:hover {
color: aqua;
}
.more:hover .trans{
transform:rotate(180deg);
color: aqua;
}
</style>
<body>
<div id="app">
<div class="more">
更多<span class="iconfont icon-xiangxiajiantou trans"></span>
</div>
</div>
<script>
const app = new Vue({
el: "#app",
data: {
}
})
</script>
</body>
</html>
网友评论