<div class="container">
<div class="box">→</div>
<div class="center"></div>
<div class="box">←</div>
</div>
.box {
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: #00aa9d;
}
/* 中心点 */
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 2px solid;
}
.container {
position: relative;
margin: 0 auto;
width: 100px;
height: 200px;
display: flex;
flex-direction: column;
justify-content: space-between;
transition: transform 2s;
}
.container:hover {
/* 沿着x轴旋转180° */
transform: rotateZ(180deg);
}
/* 初始化 */
body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.