html - 图像移出屏幕然后重新打开的动画
问题描述
我有一个标志的 png 文件,我想要动画移动到右侧,离开屏幕然后从左侧回到屏幕上。css中有什么东西可以用于这个特定目的吗?还是我必须在设计上发挥创意?
我已经使用关键帧动画将图像从左向右移动,因此我可以更多地了解动画在 css 中的工作原理,但我仍在苦苦挣扎。
<head>
<link rel="stylesheet" href="Ufatrue.css">
<title>Bashkorostan</title>
</head>
<body bgcolor="#E1E4E6">
<div id="Top">
<img src="Top.png" alt="7 Flags" align="middle">
</div>
<div id="Title">
<h>Volga Federal District News</h>
</div>
#Top {
position: relative;
animation: myanimation;
animation-duration: 8s;
animation-iteration-count: infinite;
}
@keyframes myanimation {
0% {left: -300px; top: 0px;}
25% {left: -300px; top: 0px;}
50% {left: 300px; top: 0px;}
75% {right: -300px; top: 0px;}
100% {right: 300px; top: 0px;}
}
解决方案
您可以只对 HTML 使用 marquee 标记。
.box{
width:10em;
height:10em;
background:dodgerblue;
}
<marquee behavior="scroll" onmouseover="this.stop()" onmouseout="this.start()" direction="right" scrollamount="50" scrolldelay="1"><div class="box"></div></maruquee>
推荐阅读
- java - 正则表达式:将字符串拆分为固定长度,不带分词并包括特殊字符
- reactjs - 反应测试:更新输入后道具值仍然没有改变
- c++ - 如何通过子成员函数创建线程
- php - Base64 使用 PHP 解码文本区域内的多行
- javascript - 如何使用 lodash 在多个数组中进行分组
- javascript - 如何使用纯Javascript从单击事件的一组按钮中获取按钮的ID
- php - 使用 PHP 从文件中删除扩展名,然后下载它
- react-native - react-native 所有命令都失败
- angular - 打字稿中的通用类型定义
- java - 如何使用意图而不是 putExtra 将类文件变量获取到另一个活动并通过按钮访问?