【发布时间】:2021-01-11 17:14:37
【问题描述】:
我对 CSS 相当陌生,我正在尝试学习如何旋转门。当我点击它时,门可以很好地旋转,但它看起来也像是从铰链上脱落的(垂直平移)!请问有办法改正吗?
感谢您的意见!
d3.select("#chart")
.append("image")
.attr("xlink:href", "https://i.stack.imgur.com/R0sAO.jpg")
.attr("x", 12)
.attr("y", 30)
.attr("width", "5.5em")
.attr("height", "5.5em");
d3.select("#chart")
.append("image")
.attr("xlink:href", "https://i.stack.imgur.com/ox20F.jpg")
.attr("id", "door")
.attr("x", 27)
.attr("y", 40)
.attr("width", "58")
.attr("height", "78");
$("#door").mousedown(function() {
$("#door").addClass("doorOpened");
});
.doorOpened {
animation: spin 0.7s;
animation-fill-mode: forwards;
}
@keyframes spin {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(60deg);
transform: skewY(20deg);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Revolving door</title>
</head>
<body>
<svg id="chart"></svg>
</body>
</html>
【问题讨论】:
-
转换必须全部在一行,否则最后一个是唯一使用的。但是,在这种情况下,最好了解 3d 变换 - 它们会为您“倾斜”,您可以设置视角 - 即用户相对于门站立的位置。
标签: html jquery css css-animations