實作一個正反面轉換效果,調慢大盒子.box過度效果后發現小盒子底色閃過,求解~
<style>
body {
perspective: 400px;
}
.box {
position: relative;
width: 300px;
height: 300px;
margin: 100px auto;
/* 轉換速度快時看不出來,這邊調成4s,就看到翻轉瞬間底色切換了2次 */
transition: all .4s;
transform-style: preserve-3d;
}
.box:hover {
transform: rotateY(180deg);
}
.front,
.back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
font-size: 30px;
color: #fff;
text-align: center;
line-height: 300px;
}
.front {
background-color: pink;
z-index: 1;
}
.back {
background-color: purple;
transform: rotateY(180deg);
}
</style>
<body>
<div class="box">
<div class="front">正面正面</div>
<div class="back">背面背面</div>
</div>
</body>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/126548.html
標籤:HTML(CSS)
