CSS旋轉效果
阿新 • • 發佈:2019-01-04
效果圖:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>CSS旋轉效果</title>
<style>
html, body {
width: 100%;
height: 100%;
}
/*設定外中內三層div的大小一致*/
.container, .item, .page {
width: 320px;
height: 180px;
line-height: 180px;
text-align: center;
font-size: 24px;
}
.item {
/*設定中間層旋轉時的動畫效果*/
transition: all .4s ease;
}
.page {
/*配合旋轉動畫*/
transition : .4s;
background-color: goldenrod;
box-shadow: 4px 2px 4px #999;
}
.front {
opacity: 1;
}
.back {
/*設定位置與正面重合*/
position: absolute;
top: 0;
left: 0;
/*設定透明 預先旋轉180deg*/
opacity : 0;
transform: rotateY(180deg);
}
.container:hover .item{
transform: rotateY(180deg);
}
.container:hover .front{
opacity: 0;
}
.container:hover .back{
opacity: 1;
}
</style>
<link rel="manifest" href="./static/manifest.json" />
<script src="./static/js/sw-server.js"></script>
</head>
<body>
<div class="container">
<div class="item">
<div class="page front">這是正面</div>
<div class="page back">這是反面</div>
</div>
</div>
</body>
</html>