web299.com
全部
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
首页
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
当前位置:
首页
>
网页特效
>
其他
高度可定制的jQuery瀑布流网格布局插件
分类:
其他
日期:
2024-05-14
点击(5)
评论(0)
演 示
免费下载
简介
##### 使用方法 使用该瀑布流布局插件之前要先引入jQuery和stackgrid.adem.js文件。 ```html ``` ##### HTML结构 该瀑布流网格布局插件使用的是嵌套div的HTML结构。 ```html
...
...
...
``` ##### 初始化插件 在确保所有内容都被加载之后,可以通过下面的方法来初始化该瀑布流网格布局插件。一定要确保所有的内容都被加载,这样可以使stackgrid计算出正确的高度。 ```javascript // Create a stackgrid object. var stackgrid = new $.stackgrid; var options = { column_width: 320 }; // Wrap the initializer inside window on load to // make sure to wait until all the grid contents are loaded. var $window = $(window); $window.on('load', function(){ // Initialize stackgrid! // The first two arguments are for the container selector and the item selector. stackgrid.initialize('#grid-container', '.grid-item', options); }); ``` ##### 添加新的网格 该瀑布流网格布局插件允许你动态的添加新的网格。并且这个过程不需要重新绘制所有的网格。 ```javascript // Create new grid-item. item = $("
I'm a new grid item.
"); // Append it to the grid-container. item.appendTo("#grid-container"); // *** If the new content has image(s), make sure it's loaded first before appending! // Append to stackgrid! stackgrid.append(item); ``` ##### 重新排列网格 ```javascript // Restack the grid to apply your config changes. stackgrid.config.is_fluid = false; stackgrid.restack(); // Certain changes require you to reset the grid. // These are changes that affect the dimensions of the grid-item or // if you remove any of the items. stackgrid.config.column_width = 400; stackgrid.reset(); stackgrid.restack(); ``` ##### 配置参数 下面是该瀑布流网格布局的可用配置参数。 ```javascript // The values shown here are the default ones. stackgrid.config = { // Your column width. column_width: 320, // Adjust spacing in-between grid-items. gutter: 20, // Set this as true to let stackgrid automatically // determine the number of columns based on the // viewport's width. is_fluid: true, // Set this as true to sort the grid in an vertically optimal way. is_optimized: true, // If is_fluid is false, it will // use this as the default number of columns. number_of_columns: 4, // Timeout delay to call the resize complete function. resize_delay: 300, // You can customize when and how each item is moved! // Make sure to use jQuery stop() function if you decide to // animate it. // Where you place the callback determines // when the next move operation is called. move: function(element, left, top, callback) { element.css({ left: left, top: top )}; callback(); }, // This function is used to scale the container containing // the grid-items. // The callback function starts the move operations. scale: function(element, width, height, callback) { element.css({ height: height, width: width }); callback(); } }; ``` - column_width:网格的宽度。 - gutter:网格之间的间距。 - is_fluid:是否设置为流式布局。流式布局会使网格自适应页面视区宽度。 - is_optimized:该选项设置为true可以使垂直的网格优化排序。 - number_of_columns:如果is_fluid选项设置为flase,则使用该选项的值为默认的网格列数。 - resize_delay:改变尺寸后的延迟时间。 - move:自定义什么时候以及如何移动网格。 - scale:该函数用于缩放保存网格的容器。
相关推荐
html5浪漫粒子表白文字特效
SlidesJS幻灯片特效
html5瀑布流相册特效
css3 svg实现的情人节表白鲜花动画特效
t-scroll.js基于ES6的DOM元素,过渡动画库插件
纯js写省市区三级联动效果
广告
广告