This article shares the specific code of jQuery to achieve the large-screen scrolling effect for your reference. The specific content is as follows Scenario requirements: On the big screen, the message will be played in real time, scrolling back and forth. Code: <!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org"> <head> <title>Checkbox custom style</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script> <style> * { margin: 0; padding: 0; } .contScend { width: 400px; height: 200px; background: #000000; margin: 20px auto; overflow: hidden; } .contScend ul { list-style: none; width: 100%; height: 100%; color:red; font-size: 13px; } .contScend ul li { width: 100%; height: 40px; box-sizing: border-box; line-height: 40px; text-align: center; } </style> </head> <body> <!-- Middle part --> <div class="contScend"> </div> </body> <script type="text/javascript"> $.ajax({ url: "test.json", type: 'GET', dataType: 'json', success: function(data) { var html = ""; html += '<ul>'; $.each(data, function(i, item) { // html += '<li>' + item.name + ':' + item.numb + '人' + '</li>'; }); html += '</ul>'; $(".contScend").html(html); scroll(); } }); function scroll() { //Get the current <ul> var $uList = $(".contScend ul"); var timer = null; //Touch to clear the timer $uList.hover(function() { clearInterval(timer); }, function() { //Leave to start the timer timer = setInterval(function() { scrollList($uList); }, 1000); }).trigger("mouseleave"); //Automatically trigger touch events //Scroll animation function scrollList(obj) { //Get the current <li> height var scrollHeight = $("ul li:first").height(); //Scroll out the height of a <li>$uList.stop().animate({ marginTop: -scrollHeight }, 600, function() { //After the animation ends, set the current <ul>marginTop to the initial value 0, and then splice the first <li> to the end. $uList.css({ marginTop: 0 }).find("li:first").appendTo($uList); }); } } </script> </html> test.json [{ "name": "Experience Zone Statistics", "numb": 0 }, { "name": "test909", "numb": 0 }, { "name": "test910", "numb": 0 }, { "name": "111", "numb": 0 }, { "name": "test", "numb": 0 }, { "name": "test11111", "numb": 0 }, { "name": "Memory Area Statistics", "numb": 0 }] The effect is as follows 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:
|
<<: Software Testing - MySQL (VI: Database Functions)
>>: SpringBoot integrates Activiti7 implementation code
My mysql version is MYSQL V5.7.9, please use the ...
need: In background management, there are often d...
When the scale of Docker deployment becomes large...
Preface As you all know, we have encountered many...
Page turning problem scenario B and C are on the ...
background: 1. There is a notification table in t...
1. Problem Description Today I need to check the ...
reason: MySQL 5.7.5 and up implements detection o...
Table of contents 1. Ordinary functions 2. Arrow ...
Ubuntu is a free and open source desktop PC opera...
1. In Windows system, many software installations...
1. View existing modules /usr/local/nginx/sbin/ng...
1. System installation package yum -y install mak...
Table of contents Preface What are enums in TypeS...
How to view files in a docker image 1. If it is a...