Implement waterfall stream Layout Based on JavaScript and javascript waterfall
The example in this article explains the code for implementing waterfall flow layout using native JavaScript and shares it with you for your reference. The specific content is as follows:
:
Code:
HTML
<!DOCTYPE html>
CSS code:
*{ margin: 0px; padding: 0px;}#container{ position: relative;}.box{ padding: 5px; float: left;}.box_img{ padding: 5px; border: 1px solid #cccccc; box-shadow: 0 0 5px #ccc; border-radius: 5px;}.box_img img{ width: 150px; height:auto;}
Js Code:
Window. onload = function () {imgLocation ("container", "box"); var imgData = {"data": [{"src": "2.jpg"}, {" src ": "3.jpg" },{" src ":" 4.jpg" },{ "src": "5.jpg" },{" src ":" 6.jpg" },{ "src": "7.jpg "}, {"src": "8.jpg"},]}; window. onscroll = function () {if (checkFlag () {var cparent = document. getElementById ("container"); for (var I = 0; I
I hope this article will help you learn about javascript programming.
Articles you may be interested in:
- Js-implemented beauty falls stream effect code
- Implementation of javascript adaptive width waterfall stream
- Pure js enables waterfall stream display of photos (automatically adapts to the window size)
- Analysis of waterfall stream layout: Implementation of JS + absolute positioning
- Example of a simple method for js to implement waterfall stream