JS realizes the scrolling effect of announcement online

JS realizes the scrolling effect of announcement online

This article shares the specific code of JS to achieve the scrolling effect of the announcement online for your reference. The specific content is as follows

The effect achieved is as follows: the news announcement scrolls up and down.

Code:

<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.0.min.js"></script>
 <script src="./l-by-l.min.js"></script>
 <title>Document</title>
 <style>
  * {
   padding: 0;
   margin: 0;
   box-sizing: border-box;
  }

  .notice-news {
   width: 400px;
   height: 30px;
   background-color: #fff;
   border: 1px solid #ccc;
   margin: 20px;
   border-radius: 8px;
   display: flex;
   align-items: center;
   padding: 0 10px;
   overflow: hidden;

  }

  .hron-voice {
   width: 16px;
   height: 16px;
   background-image: url('./horn.png');
   background-repeat: no-repeat;
   background-size: 100% 100%;
  }

  .news-list {
   list-style: none;
   width: 320px;
   height: 18px;
   font-size: 12px;
   margin-left: 10px;
   overflow: hidden;
   /* transition: all .5s linear; */
  }

  .news-list li {
   width: 100%;
   overflow: hidden;
   white-space: nowrap;
   text-overflow: ellipsis;
  }

  
 </style>
</head>

<body>
 <div class="notice-news">
  <div class="hron-voice"></div>
  <ul class="news-list">
   <li>HTML is called Hypertext Markup Language, which is a identification language. It consists of a series of tags. These tags can be used to unify the document format on the network and connect scattered Internet resources into a logical whole. </li>
   <li>JavaScript ("JS" for short) is a lightweight, interpreted or just-in-time compiled, high-level programming language with function-first approach. </li>
   <li>Cascading Style Sheets (full name: Cascading Style Sheets) is a computer language used to express the style of files such as HTML (an application of Standard Generalized Markup Language) or XML (a subset of Standard Generalized Markup Language). </li>
   <li>Node.js is a JavaScript runtime environment based on the Chrome V8 engine. Node.js uses an event-driven, non-blocking I/O model. </li>
  </ul>
 </div>
</body>

<script type="text/javascript">
 $(function () {
  setInterval(function () {
   $('.news-list').animate({
    marginTop: '-50px'
   }, 2000, function () {
    $(this).css({ marginTop: "0px" });
    var li = $(".news-list").children().first().clone()
    $(".news-list li:last").after(li);
    $(".news-list li:first").remove();
   })
  }, 3000)
 })
</script>

</html>

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • JavaScript to achieve the effect of scrolling up and down the bulletin board
  • Scrolling announcement effects implemented with JavaScript [based on jQuery]
  • Native js to achieve announcement scrolling effect
  • Use 10 lines of js code to achieve the effect of scrolling up and down announcements
  • js seamless scrolling upwards, website announcement effect specific code

<<:  Vuex implements a simple shopping cart

>>:  JavaScript Html to implement the mobile red envelope rain function page

Recommend

MySQL8 Installer version graphic tutorial

Installation The required documents are provided ...

Summary of Problems in Installing MySQL 5.7.19 under Linux

The first time I installed MySQL on my virtual ma...

Detailed explanation of the execution process of mysql update statement

There was an article about the execution process ...

Detailed explanation of Docker Secret management and use

1. What is Docker Secret 1. Scenario display We k...

The difference between name and value in input tag

type is the control used for input and output in t...

Summary of common functions of PostgreSQL regular expressions

Summary of common functions of PostgreSQL regular...

Detailed explanation of the role of key in React

Table of contents Question: When the button is cl...

Vue2.0 implements adaptive resolution

This article shares the specific code of Vue2.0 t...

Solve the cross-domain problem of Vue+SpringBoot+Shiro

Table of contents 1. Configure Vue front end 1. D...

MySQL 5.7.17 installation and configuration method graphic tutorial under win7

I would like to share with you the graphic tutori...

A brief analysis of React Native startReactApplication method

In this article, we sorted out the startup proces...

React Hooks Common Use Scenarios (Summary)

Table of contents 1. State Hook 1. Basic usage 2....

Several ways to remove the dotted box that appears when clicking a link

Here are a few ways to remove it: Add the link dir...

Canonical enables Linux desktop apps with Flutter (recommended)

Google's goal with Flutter has always been to...