如何使用 CSS 变换以抛物线路径 ie.curved 移动图片?
How to move a picture in a parabolic path ie.curved using CSS transform?
我正在尝试沿抛物线(圆的 25%)路径移动图像,有人可以帮忙吗。我已尝试多次使用 csstransform: rotate(18deg) translate(0px,100px)
围绕我的确切代码移动它如下 -
*{
margin: 0;
padding: 0;
}
.dash{
position: absolute;
top: 70%;
left: 40%;
width:50px;
height:50px;
background: #000;
animation: animate 5s linear infinite;
transform-origin: top;
}
@keyframes animate{
0%{
transform: rotate(0deg) translate(0px , 0px);
}
10%{
transform: rotate(-5deg) translate(0px,-50px);
}
20%{
transform: rotate(-15deg) translate(0px,-100px);
}
40%{
transform: rotate(-20deg) translate(0px,-150px);
}
60%{
transform: rotate(-30deg) translate(0px,-200px);
}
80%{
transform: rotate(-35deg) translate(0px,-250px);
}
100%{
transform: rotate(0deg) translate(0px,-300px);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<div class="dash"></div>
</body>
</html>
在那里面 div 我有一张图片..
要指定路径,请查看此图片..
请帮助我..任何帮助将不胜感激
您可以像下面这样简单地做:
.dash {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
background: #000;
animation: animate 2s linear infinite alternate;
}
@keyframes animate {
0% {
transform: rotate(90deg) translate(150px);
}
100% {
transform: rotate(0deg) translate(150px);
}
}
html {
background:radial-gradient(circle 170px at top left,transparent 95%,#000,transparent) fixed;
}
<div class="dash"></div>
也喜欢这个:
.dash {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
background: #000;
animation: animate 2s linear infinite alternate;
}
@keyframes animate {
0% {
transform: rotate(90deg) translate(150px) rotate(-90deg);
}
100% {
transform: rotate(0deg) translate(150px) rotate(0);
}
}
html {
background:radial-gradient(circle 170px at top left,transparent 95%,#000,transparent) fixed;
}
<div class="dash"></div>
我正在尝试沿抛物线(圆的 25%)路径移动图像,有人可以帮忙吗。我已尝试多次使用 csstransform: rotate(18deg) translate(0px,100px)
围绕我的确切代码移动它如下 -
*{
margin: 0;
padding: 0;
}
.dash{
position: absolute;
top: 70%;
left: 40%;
width:50px;
height:50px;
background: #000;
animation: animate 5s linear infinite;
transform-origin: top;
}
@keyframes animate{
0%{
transform: rotate(0deg) translate(0px , 0px);
}
10%{
transform: rotate(-5deg) translate(0px,-50px);
}
20%{
transform: rotate(-15deg) translate(0px,-100px);
}
40%{
transform: rotate(-20deg) translate(0px,-150px);
}
60%{
transform: rotate(-30deg) translate(0px,-200px);
}
80%{
transform: rotate(-35deg) translate(0px,-250px);
}
100%{
transform: rotate(0deg) translate(0px,-300px);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<div class="dash"></div>
</body>
</html>
在那里面 div 我有一张图片..
要指定路径,请查看此图片..
您可以像下面这样简单地做:
.dash {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
background: #000;
animation: animate 2s linear infinite alternate;
}
@keyframes animate {
0% {
transform: rotate(90deg) translate(150px);
}
100% {
transform: rotate(0deg) translate(150px);
}
}
html {
background:radial-gradient(circle 170px at top left,transparent 95%,#000,transparent) fixed;
}
<div class="dash"></div>
也喜欢这个:
.dash {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
background: #000;
animation: animate 2s linear infinite alternate;
}
@keyframes animate {
0% {
transform: rotate(90deg) translate(150px) rotate(-90deg);
}
100% {
transform: rotate(0deg) translate(150px) rotate(0);
}
}
html {
background:radial-gradient(circle 170px at top left,transparent 95%,#000,transparent) fixed;
}
<div class="dash"></div>