Implementing carousel with a single DOM node You can use backgroundImage to add multiple images and offset them to achieve a carousel effect.
/** * Play picture */ function playImage(src) { if (animaitionFinshed) return; if (!_imageEl) { _imageEl = document.createElement('div') _imageEl.className = `swiper_container`; _imageEl.style.backgroundImage = `url(${src.url})`; _imageEl.setAttribute("data-img", src.url); elContainer.appendChild(_imageEl); } else { animaitionFinshed = true; let width = elContainer.clientWidth, height = elContainer.clientHeight; let preImage = _imageEl.getAttribute("data-img"); _imageEl.style.backgroundImage = `url(${preImage}),url(${src.url})`; _imageEl.style.backgroundPositionX = `center,${width + 20}px`; setTimeout(() => { _imageEl.style.transition = "all 0.8s ease"; _imageEl.style.backgroundPositionX = `-${width + 20}px,center`; }, 0); setTimeout(() => { _imageEl.style.transition = "none"; _imageEl.style.backgroundImage = `url(${src.url}) `; _imageEl.style.backgroundPositionX = `center`; _imageEl.setAttribute("data-img", src.url) animaitionFinshed = false; }, 800) } } source code 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. |
<<: Summary of the differences between Html, sHtml and XHtml
>>: Example of deploying MySQL on Docker
I installed MySQL smoothly in Ubuntu 16.04 before...
A colleague once told me to use a temporary table...
When you browse many websites, you will find that ...
"We're writing our next set of mobile pr...
This article shares the encapsulation code of Jav...
Regarding some MySQL specifications, some compani...
Web Application Class 1. DownForEveryoneOrJustMe ...
When we use the like % wildcard, we often encount...
It is very common to use webpack to build single-...
1. The relationship between fonts and character d...
Docker-compose deploys gitlab 1. Install Docker I...
I didn't intend to write this blog, but durin...
Database SQL optimization is a common problem. Wh...
The background color of the table can be set thro...
Table of contents Layout part: <div id="a...