In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to achieve drop-down refresh in html5. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Home page css+html section:
* {margin: 0; padding: 0; list-style: none;} body {display: flex; justify-content: center; align-items: center;} .one {width: 4rem.height: 7rem.border: 1px solid red; font-size: 0.35rem Box-sizing: border-box; overflow-y: auto;} .kl {position: relative;} .lis {width: 100%; height: 1rem; line-height: 1rem; text-align: center; background: red;} .lis:nth-child (2n+1) {background: pink {height:100%; overflow: auto;-webkit-overflow-scrolling: touch;} .di {position: relative; color: # c8c9cc; font-size: 0; vertical-align: middle;} .k {width: 0.5remr; height: 0.5remr; display: inline-block; max-width: 100%; max-height: 100% Animation: theanimation 1s linear infinite;} .us {position: absolute; top: 0; left: 0; width: 100%; height: 100%; color:rgb (25,137,250)} .us: before {display: block; width: 2px; height: 25%; margin: 0 auto; background-color: currentColor; border-radius: 40%; content:'' }. Us:nth-child (1) {- webkit-transform: rotate (30deg); transform: rotate (30deg); opacity: 1;}. Us:nth-child (2) {- webkit-transform: rotate (60deg); transform: rotate (60deg); opacity: 0.9375;}. Us:nth-child (3) {- webkit-transform: rotate (90deg); transform: rotate (90deg); opacity: 0.875 }. Us:nth-child (4) {- webkit-transform: rotate (120deg); transform: rotate (120deg); opacity: 0.8125;}. Us:nth-child (5) {- webkit-transform: rotate (150deg); transform: rotate (150deg); opacity: 0.75;}. Us:nth-child (6) {- webkit-transform: rotate (180deg); transform: rotate (180deg) Opacity: 0.6875;}. Us:nth-child (7) {- webkit-transform: rotate (210deg); transform: rotate (210deg); opacity: 0.625;}. Us:nth-child (8) {- webkit-transform: rotate (240deg); transform: rotate (240deg); opacity: 0.5625;}. Us:nth-child (9) {- webkit-transform: rotate (270deg) Transform: rotate (270deg); opacity: 0.5;}. Us:nth-child (10) {- webkit-transform: rotate (300deg); transform: rotate (300deg); opacity: 0.4375;} .us:nth-child (11) {- webkit-transform: rotate (330deg); transform: rotate (330deg); opacity: 0.375 }. Us:nth-child (12) {- webkit-transform: rotate (360deg); transform: rotate (360deg); opacity: 0.3125;} @ keyframes theanimation {from {transform: rotate (0deg);} to {transform: rotate (360deg) }} drop-down refresh this is a content This is a content.
Here is a simulation of a simple drop-down refresh template.
Then there is the js section and the most important part:
Window.loading = function () {var sin = 0; var sel = null; / / timer var br = true; / / determine whether all the numbers are calculated based on var bl = true; / / determine whether ios an var all_H; / / pull-down height var xl_xu, sl_xu; / / drop-down and pull-up var str Let box = document.getElementsByClassName ('one') [0] / / fetch the entire body let box_childer = document.getElementsByClassName (' kl') [0] let li = document.querySelectorAll ('li') / / all li box.addEventListener (' touchstart', start) / / press event box.addEventListener ('scroll', (e) = > scrol (e)) / / Mobile event box.addEventListener (' touchend') End) / / Press the exit event / / box.addEventListener ('touchmove',move_lin) / / drag event function scrol (e) {/ / activity event let move_scroll = br & & bl? E.target.scrollTop: NaN all_H = box.clientHeight + move_scroll if (all_H > = e.target.scrollHeight) {/ / bl = false if (sin ^ 3) {+ + sin} else {if (xl_xu) {return} Establish (2) return false} br = false / / create a server to display the content establish () } function end () {/ / Mouse opening event bl = true} function start (e) {/ / press event bl = true} function establish (a = 0) {/ / add dom plus if (a = 2) {/ / indicate that it is the last xl_xu = document.createElement ('div') Xl_xu.style.textAlign = 'center' xl_ Xu [XSS _ clean] =' box_childer.appendChild (xl_xu) return} if (xl_xu) {/ / delete box_childer.removeChild (xl_xu)} xl_ first Xu = document.createElement ('div') xl_xu.style.textAlign =' center' xl_ Xu [XSS _ clean] = str box_childer.appendChild (xl_xu) sel = setTimeout (() = > {box_childer.removeChild (xl_xu) xl_xu = null clearTimeout (sel) Let a = Array.from ({length: 5}, _ = > document.createElement ('li')) for (let I = 0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.