javascript - css怎么解决hover鼠标移除后的效果
本文介绍了javascript - css怎么解决hover鼠标移除后的效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
想要实现背景图片鼠标移入左右翻变换背景图的动效,但是移出的时候想要去除掉翻转,直接把背景图片换回来,捣鼓了许多都不知道这么弄,就大神临摹求解。。。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D</title>
<style>
ul li{
list-style: none;
cursor: pointer;
position: relative;
}
.flipBtn, .flipBtn_face{
position: absolute;
width:167px;
height:116px;
}
.flipBtn {
transition: transform 0.4s;
transform-style: preserve-3d;
cursor: pointer;
position: relative;
float: left;
}
.flipBtn_front{
backface-visibility: hidden;
}
.flipBtn_front{
width:151px;
height:100px;
margin:8px;
background:url(./image/pic00.jpg) no-repeat;
}
.flipBtn_back{
width:151px;
height:100px;
margin:8px;
background:url(./image/pic01.jpg) no-repeat;
}
.flipBtn_mid.flipBtn_face{
transform: rotateY(90deg);
-webkit-transform: rotateY(90deg);
-moz-transform: rotateY(90deg);
}
.flipBtn:hover{
transform:rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
}
</style>
</head>
<body>
<ul class="flipBtnWrapper">
<li class="flipBtn">
<a class="flipBtn_face flipBtn_back"></a>
<div class="flipBtn_face flipBtn_mid"></div>
<div class="flipBtn_face flipBtn_front"></div>
</li>
</ul>
</body>
</html>
解决方案
你是想hover的时候有反转的效果,而移开时直接变换没有反转?那你把transition这个属性放在hover里就行了
这篇关于javascript - css怎么解决hover鼠标移除后的效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文