<body>
<div></div>
</body>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #0d0f1b;
overflow: hidden;
}
div {
width: 100px;
height: 100px;
background-color: white;
transition: transform 0.5s;
}
div:hover {
transform: translate(100px, 100px);
}
- transition 标识过渡
其中属性property可以写成all,表示对所有属性都会有该过渡方案
如改变旋转的中心,默认以元素中心为旋转中心