html - 如何将我的图片动画到另一个点
问题描述
HTML 和 CSS 的新手。谁能教我如何将我的图片从我当前的位置动画到另一个位置?例如,从移动"top: 280px: left 600px;"
到"top:180px; left 500px;"
需要人指导一下,谢谢。以下是我当前的代码:
#robot {
position: fixed;
top: 280px;
left: 600px;
border-radius: 50%;
width: 50px;
height: 60px;
}
body {
height: 100%;
width: 100%;
background-image: url('TPHRG floorplan1.png');
background-repeat: no-repeat;
background-attachment: fixed;
/* background-position: center; */
background-size: 980px 400px, cover;
}
<img id="robot" src="https://img.favpng.com/20/7/18/clip-art-robot-free-content-image-vector-graphics-png-favpng-pJhfbKDrGy0yuQsKVTrjEu7br.jpg">
解决方案
是的,你可以通过简单的使用 css 来做到这一点。
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#robot {
position: fixed;
top: 280px;
left: 600px;
border-radius: 50%;
width: 50px;
height: 60px;
-webkit-animation-name: example; /* Safari 4.0 - 8.0 */
-webkit-animation-duration: 4s; /* Safari 4.0 - 8.0 */
animation-name: example;
animation-duration: 4s;
}
body {
height: 100%;
width: 100%;
background-image: url('TPHRG floorplan1.png');
background-repeat: no-repeat;
background-attachment: fixed;
/* background-position: center; */
background-size: 980px 400px, cover;
}
/* Safari 4.0 - 8.0 */
@-webkit-keyframes example {
from {top: 280px;left:600px;}
to {top: 180px;left:500px;}
}
/* Standard syntax */
@keyframes example {
from {top: 280px;left:600px;}
to {top: 180px;left:500px;}
}
</style>
<body>
<img id="robot" src="https://www.w3schools.com/images/compatible_chrome.gif">
<?php ?>
</body>
</html>
推荐阅读
- android - java.lang.reflect.InvocationTargetException - android.view.InflateException:二进制 XML 文件第 14 行:膨胀类 android.widget.TextView 时出错
- node.js - Mongodb聚合:在$group阶段插入嵌套字段
- google-visualization - 使谷歌图表线条占据整个面积图
- ssl - 在数据包丢失的情况下缓慢的 DTLS 握手
- spring - Spring AOP 以崇高的顺序运行
- extjs - Ext JS Classic 7.1 + Modern 主题:绑定 fieldLabel 和 emptyText 不起作用
- uipath - 在 UiPath Orchestrator 中创建机器人
- react-native - 自定义字体不适用于 React-Native 0.62
- python - AttributeError:“NoneType”对象在 odoo 13 中没有属性“组”
- javascript - 使用服务工作者在后台同时使用缓存*和*更新