在 HTML 中移动文本也称为滚动文本。我们可以以一定的时间间隔速度向各个方向滚动文本。 标签用于进行下一步操作。文本滚动有 4 个方向,即左方向、右方向、上方向、下方向。通过设置行为属性在封闭区域内移动文本。
实时示例: 假设我们的网站上经常有重要的更新内容。如果内容始终稳定,用户就无法关注该内容,因此为了吸引用户的注意力,我们必须始终滚动更新的内容。根据用户的要求,我们可以指示内容滚动到哪一侧。达到这个要求
为什么我们在 HTML 中使用 CSS?
提供所有页面之间通用的逻辑;我们不再在每个 HTML 页面中编写相同的样式逻辑,而是使用 CSS 文件来编写通用逻辑。并在每个 HTML 页面中使用 包含此 CSS 页面。标签。
Marquee 标签在 HTML 中如何工作?
可以通过应用
语法 #1
<marquee> //some text to move </marquee>
语法#2
<marquee direction="”left" or right up down> //some text to move </marquee>
语法#3
<marquee behavior="alternate"> //it makes the text back direction by touching the border of the page. //some text to move </marquee>
语法#4
<marquee direction="”left”" scrollamount="5">// scrollamount used to set the scrolling text speed //some text to move </marquee>注意:如果我们没有提供任何方向属性,默认选取框方向是离开。
在 HTML 中实现移动文本的示例
以下是提到的示例:
示例#1
默认字幕标签
代码:
<title>Move Text</title> <style> body { background-color: green; text-align: center; color: white; font-family: Arial; } </style> <h1 id="Moving-Text-with-Marquee-Tag">Moving Text with Marquee Tag</h1> <marquee> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee>
输出:
说明:正如您在上面的文本中看到的,即使我们没有提及任何方向,它也是从右向左移动的,因此它是默认的选取框标签。
示例#2
选框标签位于正确的方向。
代码:
<title>Move Text</title> <style> body { background-color: maroon; text-align: center; color: white; font-family: Arial; } </style> <h1 id="Moving-Text-with-Marquee-Tag">Moving Text with Marquee Tag</h1> <marquee direction="right"> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee>
输出:
说明:如上面的文字所示,通过将方向属性设置为右侧,从左向右移动。
示例 #3
顶部方向的字幕
代码:
<title>Move Text</title> <style> body { background-color: blue; text-align: center; color: white; font-family: Arial; } </style> <h1 id="Moving-Text-with-Marquee-Tag">Moving Text with Marquee Tag</h1> <marquee direction="up"> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee>
输出:
说明:如上面的文字所示,通过将方向属性设置为向上,从下到上移动。
示例#4
底部方向的选框。
代码:
<title>Move Text</title> <style> body { background-color: orange; text-align: center; color: white; font-family: Arial; } </style> <h1 id="Moving-Text-with-Marquee-Tag">Moving Text with Marquee Tag</h1> <marquee direction="down"> 2020 is year bewildered each and every individual of the world due to pandemic COVID-19. This disease is caused by CARONA virus. Till date there is no medicine or vaccine for this disease. So the only option in our hands is to follow instructions strictly announced by World Health Organization. Italy is affected with this virus more worsen because of there is no initial preventive measures in the country. Fight back against the virus every individual should home quarantine. Clean the hands every time if are out from the same place. Strictly say no to hand shake instead respect them back with namaskar. Do not contact any person until state and center curfew is over. Now India also greatly affected by this COVID-19 virus because of foreigners. Who ever come to India from other country they must undergone to quarantine at least 14 days. After finishing quarantine they must go for CARONA test. </marquee>
输出:
说明:如上面的文字所示,通过将方向属性设置为向下,从上到下移动。
示例#5
具有行为属性的字幕。
代码:
<title>Move Text</title> <style> body { background-color: lightblue; text-align: center; color: brown; font-family: Arial; border: solid 2px red; } </style> <h1 id="Moving-Text-with-Marquee-Tag">Moving Text with Marquee Tag</h1> <marquee behavior="alternate"> Hi, I am an alternate proeprty </marquee>
输出:
说明:如上面的文字所示,通过将行为属性设置为alternate,通过触摸边框从左到右和从右到左移动。
示例 #6
具有滚动量属性的字幕。
代码:
<title>Move Text</title> <style> body { background-color: fuchsia; text-align: center; color: white; font-family: Arial; border: solid 2px red; } </style> <h1 id="Moving-Text-with-Marquee-Tag">Moving Text with Marquee Tag</h1> <marquee direction="left" scrollamount="2"> Paramesh </marquee> <marquee scrollamount="4"> Amardeep </marquee> <marquee scrollamount="6"> Harinath-Rajitha </marquee>
输出:
说明:正如您在上面的文字中看到的,从右向左移动的时间不同,因此它们都位于不同的位置。
结论
通过 marquee 标签实现 HTML 中文本的移动。我们可以根据需要对文本进行左、右、上、下移动。此字幕功能主要用于电视频道定期更新以吸引用户注意力。
以上是在 HTML 中移动文本的详细内容。更多信息请关注PHP中文网其他相关文章!

在Bootstrap4中实现多项目轮播的解决方案在Bootstrap4中实现多项目轮播并不是一件简单的事情。虽然Bootstrap...

如何实现鼠标滚动事件穿透效果?在我们浏览网页时,经常会遇到一些特别的交互设计。比如在deepseek官网上,�...

无法直接通过CSS修改HTML视频的默认播放控件样式。1.使用JavaScript创建自定义控件。2.通过CSS美化这些控件。3.考虑兼容性、用户体验和性能,使用库如Video.js或Plyr可简化过程。

在手机上使用原生select的潜在问题在开发移动端应用时,我们常常会遇到选择框的需求。通常情况下,开发者倾...

在手机上使用原生select的弊端是什么?在移动设备上开发应用时,选择合适的UI组件是非常重要的。许多开发者�...

使用Three.js和Octree优化房间内第三人称漫游的碰撞处理在Three.js中使用Octree实现房间内的第三人称漫游并添加碰�...

使用原生select在手机上的问题在移动设备上开发应用时,我们经常会遇到需要用户进行选择的场景。虽然原生sel...

探究鼠标滚动事件的实现原理在浏览一些网站时,你可能注意到某些页面元素在鼠标悬停时仍然允许滚动整个页...


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。