JQuery Masonry-a powerful dynamic irregular layout plug-in that makes your webpage 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.
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
. 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
- });
- });
Jquerymasonryminjs Click Event trigger on the page to add the length of the specified unit.
Look at the layer of your css. Is it overflow: What is hiden set to hide when it exceeds the upper limit?
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.