使用 CSS Animation 为 transform-origin 属性添加动画
cssweb developmentfront end technology更新于 2024/11/9 18:52:17
要使用 CSS 为 transform-origin 属性添加动画,您可以尝试运行以下代码
示例
<!DOCTYPE html>
<html>
<head>
<style>
#demo1 {
position: relative;
height: 300px;
width: 400px;
border: 2px solid black;
margin: 100px;
padding: 5px;
}
#demo2 {
padding: 30px;
position: absolute;
border: 1px solid black;
background-color: orange;
transform: rotate(45deg);
transform-origin: 30% 10%;
animation: mymove 3s infinite;
}
@keyframes mymove {
30% {
transform-origin: 0 0 0;
}
}
</style>
</head>
<body>
<h1>CSS transform-origin property</h1>
<div id = "demo1">
<div id="demo2">Demo</div>
</div>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

