<html> <head> <meta charset="utf-8" /> <title>Picture Lazy Loading</title> <style type="text/css"> .Demo{width: 1000px;margin: 50px auto;} .Demo>div{display: inline-block;width: 485px;height: 400px;margin-right: 25px;margin-bottom: 25px;} .Demo>div:nth-child(2n){margin-right: 0;} .Demo>div>img{width: 100%;height: 100%;} </style> </head> <body> <div class="Demo"> <div> <img src="img/timg.gif" data-original="img/1.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/2.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/3.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/4.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/5.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/6.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/7.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/8.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/9.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/10.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/11.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/12.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/13.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/1.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/2.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/999.jpg" class="lazy"/> </div> </div> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="https://cdn.bootcss.com/jquery_lazyload/1.9.7/jquery.lazyload.min.js"></script> <script type="text/javascript"> $(function(){ $(".lazy").lazyload({effect:"fadeIn",threshold:5}); }); </script> </body> </html>Parameter setting
$(".xxx").lazyload({
placeholder : "img/grey.gif", //Use pictures to occupy space ahead of time
// Placement holder, the value of which is an image path. This image is used to occupy the position of the image to be loaded. When the image is loaded, the placeholder is hidden.
effect: "fadeIn", // What is the effect of loading
// Effect (special effects), values show (direct display), fadeIn (fade in), slideDown (drop-down), etc., commonly used fadeIn
threshold: 200, // Start loading ahead of time
// threshold, the value is a number, representing the height of the page. If set to 200, it means that the scrollbar starts loading pictures when it is still 200 height away from the target position, so that users can not be aware of it.
event: 'click', // Load only when event triggers
// event, with click, mouseover, sporty, foobar(... ) The last two values are not tested.
container: $("#Container", // Implement the effect of the image in a container
// The value of container is a container. lazyload takes effect by default when the browser scrollbar is pulled. This parameter allows you to load the pictures in turn when pulling the scrollbar of a DIV.
failurelimit : 10 // When Picture Sorting is Chaotic
// failurelimit, the value is a number. lazyload defaults to continue loading when it finds the first image that is not in the visible area, but when the HTML container is confused, there may be images in the visible area that are not loaded. failurelimit is intended to load N pictures outside the visible area to avoid this problem.
});
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < title > Image lazy loading </title > <style type="text/css"> .Demo{width: 1000px;margin: 50px auto;} .Demo>div{display: inline-block;width: 485px;height: 400px;margin-right: 25px;margin-bottom: 25px;} .Demo>div:nth-child(2n){margin-right: 0;} .Demo>div>img{width: 100%;height: 100%;} </style> </head> <body> <div class="Demo"> <div> <img src="img/timg.gif" data-original="img/1.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/2.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/3.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/4.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/5.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/6.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/7.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/8.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/9.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/10.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/11.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/12.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/13.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/1.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/2.jpg" class="lazy"/> </div> <div> <img src="img/timg.gif" data-original="img/999.jpg" class="lazy"/> </div> </div> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="https://cdn.bootcss.com/jquery_lazyload/1.9.7/jquery.lazyload.min.js"></script> <script type="text/javascript"> $(function(){ $(".lazy").lazyload({effect:"fadeIn",threshold:5}); }); </script> </body> </html>Parameter setting
$(".xxx").lazyload({
Placement holder: "img/grey.gif", // preoccupy with pictures
// Placement holder, the value of which is an image path. This image is used to occupy the position of the image to be loaded. When the image is loaded, the placeholder is hidden.
Effect:'fadeIn', // What effect is the load using?
// Effect (special effects), values show (direct display), fadeIn (fade in), slideDown (drop-down), etc., commonly used fadeIn
threshold: 200, // start loading ahead of time
// threshold, the value is a number, representing the height of the page. If set to 200, it means that the scrollbar starts loading pictures when it is still 200 height away from the target position, so that users can not be aware of it.
Event:'click', // loads only when the event triggers
// event, with click, mouseover, sporty, foobar(... ) The last two values are not tested.
container: $("#container"), // / Implementing effects on images in a container
// The value of container is a container. lazyload takes effect by default when the browser scrollbar is pulled. This parameter allows you to load the pictures in turn when pulling the scrollbar of a DIV.
Failurelimit: 10 // When Picture Sorting is Chaotic
// failurelimit, the value is a number. lazyload defaults to continue loading when it finds the first image that is not in the visible area, but when the HTML container is confused, there may be images in the visible area that are not loaded. failurelimit is intended to load N pictures outside the visible area to avoid this problem.
});
Initial use of lazy load plug-ins
Posted by maxpup979 on Sat, 18 May 2019 15:04:49 -0700