JQuery Masonry-powerful dynamic irregular layout plug-in makes your web page more natural, jquerymasonry-
MasonryIt is a powerful jQuery dynamic grid layout plug-in that can help developers quickly develop interface effects similar to clip art. The effect of float in CSS is not the same as that of float. float is first horizontally arranged and then vertically arranged. With Masonry, elements are vertically arranged, then place the next element in the next development area of the grid. This effect minimizes the gap between elements of different heights in the vertical direction. As follows:
As you can see in the figure, using float to process elements of different heights in the grid layout results in a large interval between elements in the vertical direction.MasonryAfter processing, the interval decreases.
A front-end UI framework that can improve development efficiency by 500%!
Usage
First, import the class library as follows:
. Code
- <Script src = "// ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js">
- </Script> <script src = "/path/to/jquery. masonry. min. js"> </script>
Then, execute masonry for the element container as follows:
. Code
- $ (Function (){
- $ ('# Iner'). masonry ({
- // Options
- ItemSelector: '. item ',
- ColumnWidth: 240
- });
- });
Html code
. Code
- <Div id = "container">
- <Div class = "item">... </div>
- <Div class = "item">... </div>
- <Div class = "item">... </div>
- ...
- </Div>
Css can improve the development efficiency by 500%!
. Code
- . Item {
- Width: 220px;
- Margin: 10px;
- Float: left;
- }
If the elements you load contain images, make sure thatMasonryRun the following code after all images are loaded:
. Code
- Var $ container = $ ('# iner ');
- $ Container. imagesLoaded (function (){
- $ Container. masonry ({
- ItemSelector: '. item ',
- ColumnWidth: 240
- });
- });
Javascript or jquery plug-in masonry, which can be used directly.
Sent...
What is the principle of waterfall layout or jquery masonry?
Masonry has nothing to do with jQuery.
It is calculated by the width and height of the block elements that have been laid out and is absolutely positioned.