<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>css3 翻牌</title>
</head>
<body>
<style>
* {
margin: 0;
padding: 0;
}
ul,
li {
margin: 0;
padding: 0;
list-style: none;
}
.flip-container,
.front1,
.back1 {
width: 283px;
height: 283px;
}
.front1,
.back1 {
position: absolute;
top: 0;
left: 0;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
transition: 0.6s ease-out;
-webkit-transition: .6s ease-out;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
}
.front1 img,
.back1 img {
width: 283px;
height: 283px;
overflow: hidden;
}
.front1 {
z-index: 2;
transform: rotateY(0deg);
-webkit-transform: rotateY(0deg);
}
.back1 {
z-index: 1;
transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
}
.back2 {
transform: rotateY(0deg);
-webkit-transform: rotateY(0deg);
z-index: 2;
}
.front2 {
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
z-index: 1
}
</style>
<ul>
<li class="flip-container ">
<div class="front1 flipper"><img src="./快捷方式/壁紙/2.jpg"></div>
<div class="back1 flipper"><img src="./快捷方式/壁紙/1.jpg"></div>
</li>
</ul>
</body>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
let is1 = true;
document.getElementsByClassName('flip-container')[0].onclick = function(){
if(is1) {
$(this).find('.front1').addClass('front2');
$(this).find('.back1').addClass('back2');
}else{
$(this).find('.front1').removeClass('front2');
$(this).find('.back1').removeClass('back2');
}
is1 = !is1;
}
</script>
</html>
到此這篇關于HTML5實現(xiàn)移動端點擊翻牌功能的文章就介紹到這了,更多相關html5點擊翻牌內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持腳本之家!