css 翻轉特效
來(Come)源:奇站網絡 浏覽量:217 發布日期: 2024-04-19
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
.flip-card {
perspective: 1000px;
/* 創建3D效果 */
}
.flip-card-inner {
width: 200px;
height: 200px;
/* background-color: #f5f5f5; */
transition: transform 0.6s;
transform-style: preserve-3d;
}
.flip-card-front,
.flip-card-back {
backface-visibility: hidden;
/* 隐藏翻轉的(of)背面 */
position: absolute;
width: 100%;
height: 100%;
transition: transform 1s;
z-index: 99;
}
.flip-card-front {
background-color: antiquewhite;
}
.flip-card-back {
background-color: aquamarine;
transform: rotateY(180deg);
/* 初始狀态下翻轉背面 */
}
.flip .flip-card-front {
transform: rotateY(-180deg);
}
.flip .flip-card-back {
transform: rotateY(0);
}
</style>
<body>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
正面
</div>
<div class="flip-card-back">
背面
</div>
</div>
</div>
<button onclick="flipCard()">點擊翻轉卡片</button>
</body>
<script>
function flipCard() {
var card = document.querySelector('.flip-card');
card.classList.toggle('flip');
}
</script>
</html>
标簽:
- 版權所有:奇站網絡 轉載請注明出(out)處
- 廈門極極網絡科技有限公司,專業提供網站建設,響應式網站建設,小程序開發,系統定制開發。
- 軟件開發咨詢熱線:吳小姐 13313868605