HTML 代码实现图片自动旋转 360 度
以下是一个简单的 HTML 代码示例,将一个图片自动旋转 360 度:
<!DOCTYPE html>
<html>
<head>
<title>自动旋转图片</title>
<style>
#image {
width: 300px;
height: 300px;
animation: spin 2s infinite linear;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<img id='image' src='http://example.com/image.jpg' alt='旋转图片' />
</body>
</html>
在样式中,我们使用@keyframes创建了一个名为spin的动画,它从0deg旋转到360deg,持续时间为2秒,并且无限循环。然后,我们将这个动画应用到<img>元素上,使它自动旋转起来。请记得将src属性替换为您自己的图片 URL。
原文地址: https://www.cveoy.top/t/topic/oPML 著作权归作者所有。请勿转载和采集!