微网站-上拉、下拉刷新(重新请求数据)_html/css_WEB-ITnose
下面dropload.min.js闪亮登场,我们直奔主题PC端的分页和移动端的分页是不一样的,如果移动端像PC端那样点击上一页、下一页,或者点击具体的页码,那样用户体验是非常差的。上拉刷新、下拉刷新这样的操作,是我们希望实现的效果,那么这种效果该如何实现呢?
- 项目准备
- zepto.min.js
- dropload.min.js
- 上拉下拉刷新的css样式(下面会详情说)
- 项目效果图1.这是上拉刷新
pic1.png
2.这是上拉刷新
pic2.png
- 图上的加载中的效果是如何加上去的?
页面源码<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>demo</title> <link rel="stylesheet" href="index.css"></head><body> <div class="wrap"> <div class="inner"> <div class="lists"> <a class="item" href="#"> <img src="/static/imghw/default1.png" data-src="goods.jpg" class="lazy" alt=""> <h3 id="文字描述文字描述">1文字描述文字描述</h3> <span class="date">2015-11-27</span> </a> <a class="item" href="#"> <img src="/static/imghw/default1.png" data-src="goods.jpg" class="lazy" alt=""> <h3 id="文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述">2文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述文字描述</h3> <span class="date">2015-11-27</span> </a> <a class="item" href="#"> <img src="/static/imghw/default1.png" data-src="goods.jpg" class="lazy" alt=""> <h3 id="文字描述文字描述文字描述文字描述文字描述">3文字描述文字描述文字描述文字描述文字描述</h3> <span class="date">2015-11-27</span> </a> <a class="item" href="#"> <img src="/static/imghw/default1.png" data-src="goods.jpg" class="lazy" alt=""> <h3 id="文字描述文字描述文字描述文字描述文字描述">4文字描述文字描述文字描述文字描述文字描述</h3> <span class="date">2015-11-27</span> </a> <a class="item" href="#"> <img src="/static/imghw/default1.png" data-src="goods.jpg" class="lazy" alt=""> <h3 id="文字描述文字描述文字描述文字描述文字描述">5文字描述文字描述文字描述文字描述文字描述</h3> <span class="date">2015-11-27</span> </a> </div> </div></div><script src="zepto.min.js"></script><script src="dropload.min.js"></script><script src="index.js"></script></body></html>
Copy after login我们可以在loadUpFn,loadDownFn中指定新的ajax请求,将ajax返回的结果按照页面所需的形式追加到容器中。说到这里,还没有结束,页面中的加载中的动画是怎么实现的呢?细心的估计已经看到了上面的js中,有这么一段代码:index.js// droploadvar dropload = $('.inner').dropload({ domUp : { domClass : 'dropload-up', domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>', domUpdate : '<div class="dropload-update">↑释放更新</div>', domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>' }, domDown : { domClass : 'dropload-down', domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>', domUpdate : '<div class="dropload-update">↓释放加载</div>', domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>' }, loadUpFn : function(me){ alert("上拉刷新操作"); me.resetload(); }, loadDownFn : function(me){ alert("下拉刷新操作"); me.resetload(); }});
Copy after login这里,我通过css3动画来实现了类似gif动态图的效果,附上源码:domUp : { domClass : 'dropload-up', domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>', domUpdate : '<div class="dropload-update">↑释放更新</div>', domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>' }, domDown : { domClass : 'dropload-down', domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>', domUpdate : '<div class="dropload-update">↓释放加载</div>', domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>' },
Copy after login好了,实现这个效果就这么多内容。这里是很灵活的,你也可以自己组织加载请求时得动画效果。快动手试试,应用在你的项目中吧~(PS:列表的css源码不在此,如果你想要整个工程的源码,你可以发我简信,或者在我的个人主页加我微信~).dropload-up,.dropload-down { position: relative; height: 0; overflow: hidden; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0)}.dropload-refresh,.dropload-update,.dropload-load { position: absolute; left: 50%; bottom: 0; width: 100%; height: 50px; line-height: 50px; text-align: center; -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0)}.dropload-down .dropload-refresh,.dropload-down .dropload-update,.dropload-down .dropload-load { top: 0; bottom: auto}.dropload-load .loading { display: inline-block; height: 15px; width: 15px; border-radius: 100%; margin: 6px; border: 2px solid #666; border-bottom-color: transparent; vertical-align: middle; -webkit-animation: rotate .75s linear infinite; animation: rotate .75s linear infinite}@-webkit-keyframes rotate { 0% { -webkit-transform: rotate(0deg) } 50% { -webkit-transform: rotate(180deg) } 100% { -webkit-transform: rotate(360deg) }}@keyframes rotate { 0% { transform: rotate(0deg) } 50% { transform: rotate(180deg) } 100% { transform: rotate(360deg) }}
Copy after login

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.
