热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在HTML中滑动句子中的单词-HowtoslideawordinasentenceinHTML

Isitpossible,usingcssorJavascripttosildeawordinasentence?Ivethebelow,forslidingt

Is it possible, using css or Javascript to silde a word in a sentence? I've the below, for sliding text. When the second sentence is shown, the word 'Data' to be then replaced with Process, then Technology, then Formula. Until all the words are shown the next sentence should not be shown.

是否可以使用css或Javascript来句子中的单词?我在下面,为了滑动文字。当显示第二个句子时,然后将“数据”一词替换为“处理”,“技术”,“公式”。在显示所有单词之前,不应显示下一句。

Tried using setInterval, get the display text from the div using innerText and write conditions to remove/re-add class. But, innerText always giving all the text inside the div.

尝试使用setInterval,使用innerText从div获取显示文本,并写入条件以删除/重新添加类。但是,innerText总是在div中提供所有文本。

HTML:

Manage collaborative process

Three level security to protect your Data

CSS:

.marquee.down p {
    transform:translateY(-100%);
    -moz-transform:translateY(-100%);
    -webkit-transform:translateY(-100%);
}

.marquee.down p:nth-child(1) {
    animation: down-one 10s ease infinite;
    -moz-animation: down-one 10s ease infinite;
    -webkit-animation: down-one 10s ease infinite;
}

.marquee.down p:nth-child(2) {
    animation: down-two 10s ease infinite;
    -moz-animation: down-two 10s ease infinite;
    -webkit-animation: down-two 10s ease infinite;
}

1 个解决方案

#1


1  

You can achieve this via CSS-animations:

您可以通过CSS动画实现此目的:

.sliding-words-wrapper {
  vertical-align: top;
  display: inline-block;
  overflow: hidden;
  /* set height to fit one item */
  height: 18.4px;
}

.sliding-words {
  display: inline-flex;
  flex-direction: column;
  position: relative;
  top: 0;
  animation: slide-words 10s linear infinite;
}

@keyframes slide-words {
  from {
    top: 0;
  }
  to {
    /* (Word count - 1) * 100% */
    top: -300%;
  }
}

Manage collaborative process

Three level security to protect your
Data Process Technology Formula

If you need to show this animation after some event (e.g. showing text) you can set its state to paused (via CSS property animation-play-state: paused), then after some event to animation-play-state: running via Javascript.

如果您需要在某个事件(例如显示文本)后显示此动画,您可以将其状态设置为暂停(通过CSS属性animation-play-state:paused),然后在某个事件之后设置为动画播放状态:通过Javascript运行。


推荐阅读
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • Iwouldliketobeabletohaveasidebarthatcanbetoggledinandoutonabuttonpress.However ... [详细]
  • 但有时候,需要当某事件触发时,我们先做一些操作,然后再跳转,这时,就要用JAVASCRIPT来实现这一跳转功能。下面是具体的做法:一:跳转到新页面,并且是在新窗口中打开时:复制代码代码如下:fu ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 本文介绍了腾讯最近开源的BERT推理模型TurboTransformers,该模型在推理速度上比PyTorch快1~4倍。TurboTransformers采用了分层设计的思想,通过简化问题和加速开发,实现了快速推理能力。同时,文章还探讨了PyTorch在中间层延迟和深度神经网络中存在的问题,并提出了合并计算的解决方案。 ... [详细]
  • VueCLI多页分目录打包的步骤记录
    本文介绍了使用VueCLI进行多页分目录打包的步骤,包括页面目录结构、安装依赖、获取Vue CLI需要的多页对象等内容。同时还提供了自定义不同模块页面标题的方法。 ... [详细]
  • 图像因存在错误而无法显示 ... [详细]
  • 合并列值-合并为一列问题需求:createtabletab(Aint,Bint,Cint)inserttabselect1,2,3unionallsel ... [详细]
  • 如何使用Python从工程图图像中提取底部的方法?
    本文介绍了使用Python从工程图图像中提取底部的方法。首先将输入图片转换为灰度图像,并进行高斯模糊和阈值处理。然后通过填充潜在的轮廓以及使用轮廓逼近和矩形核进行过滤,去除非矩形轮廓。最后通过查找轮廓并使用轮廓近似、宽高比和轮廓区域进行过滤,隔离所需的底部轮廓,并使用Numpy切片提取底部模板部分。 ... [详细]
  • 本文介绍了DataTables插件的官方网站以及其基本特点和使用方法,包括分页处理、数据过滤、数据排序、数据类型检测、列宽度自动适应、CSS定制样式、隐藏列等功能。同时还介绍了其易用性、可扩展性和灵活性,以及国际化和动态创建表格的功能。此外,还提供了参数初始化和延迟加载的示例代码。 ... [详细]
  • SQL Server 内存中OLTP内部机制概述(一)
    内存中OLTP(项目名为“Hekaton”)是一个新的完全集成到SQLServer中的数据库引擎组件。它专为访问内存常驻数据的OLTP工作负荷而进行优化。内存中OLTP有助于OLT ... [详细]
  • 本文整理了常用的CSS属性及用法,包括背景属性、边框属性、尺寸属性、可伸缩框属性、字体属性和文本属性等,方便开发者查阅和使用。 ... [详细]
  • 本文整理了Java中org.apache.pig.backend.executionengine.ExecException.<init>()方法的一些代码 ... [详细]
  • Whyusingstringsaskeysofarray,consoleisshowingthatarraywithoutthesedeclaredvaluesand ... [详细]
author-avatar
罗群霞
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有