1. Demand A picture moves from left to right in an infinite loop 2. Code Since it is applied on mobile devices, rem units are used, and the following problems also occur here. HTML <div class="dog"></div> CSS .dog { width: 5.4rem; \\Image width height: 3.04rem; \\Image height background-image: url(head.jpg); background-size: 5.4rem 3.04rem; \\Image width and height background-position: -5.4rem 0; animation: run 2s linear infinite; } @keyframes run { from {background-position: -5.4rem 0;} to {background-position: 0 0;} } 3. Problem There is no problem on the PC side, but on the mobile side (perhaps due to recalculation of the font size?) you will find that the movement speed is inconsistent with the settings, and the image cannot be seamless. 4. Reasons Unknown, no relevant information found. It seems that the problem is caused by dynamic calculation of font-size. 5. Solution After testing, it was found that it is normal to add animation to the image after the file is loaded. So modify the code: JS $(document).ready(function(){ remReSize(); setTimeout(function() { $('.dog').css('animation', 'run 2s linear infinite'); }, 0); }); 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. |
<<: Possible reasons why the input type="reset" tag in HTML is invalid (does not work).
>>: Use of Vue3 pages, menus, and routes
Dynamic rem 1. First, let’s introduce the current...
We can use the scp command of Linux (scp cannot b...
Table of contents First look at the effect: accom...
Preface HTTP is a stateless communication protoco...
Preface This article contains 1. Several major co...
1. Download the axios plugin cnpm install axios -...
Table of contents 1. router-view 2. router-link 3...
1. Use the mysql/mysql-server:latest image to qui...
Environment Preparation Docker environment MySQL ...
reason The mysql version that nacos's pom dep...
When using Maven to manage projects, how to uploa...
Table of contents 1. Install the psutil package S...
Many times, after we install a web service applic...
1. Introduction WHMCS provides an all-in-one solu...
Table of contents 1. Original Definition 2. JS op...