Masonry是一款很好用的jquery网页布局插件,它可以去掉不同高度div之间的空白,让你的网页看上去更加的整齐、漂亮!效果如下图所示

官网插件下载地址以及详解地址:http://masonry.desandro.com/

masonry配置对象Options

Options are set with an object as second argument to the .masonry() method. All options are optional, and do not need to be set, but itemSelector and columnWidth are recommended.

$('#container').masonry({

itemSelector: '.box',

columnWidth: 240,

animationOptions: {

duration: 400

}

});

配置项目

类型

默认值

说明/示例

animationOptions

Object

{queue:false,duration:500}

Options used for jQuery animation. See the jQuery API for animate options for details. More details in Animating.

columnWidth

Integer

Width in pixels of 1 column of your grid. If no columnWidth is specified, Masonry uses the width of the first item element.

Recommended if your layout has item elements that have multiple-column widths.

To set a dynamic column width, you can pass in a function that returns the value column width. The function provides an argument for the width of the container. Use this technique for fluid or responsive layouts.

$('#container').masonry({

// set columnWidth a fraction of the container width

columnWidth: function( containerWidth ) {

return containerWidth / 5;

}

});

containerStyle

Object

{ position: 'relative' }

CSS properties applied to the container. Masonry uses relative/absolute positioning to position item elements.

gutterWidth

Integer

0

Adds additional spacing between columns.See Demo: Gutters

isAnimated

Boolean

false

Enables jQuery animation on layout changes. See Docs: Animating. More details in Animating.

isFitWidth

Boolean

false

If enabled, Masonry will size the width of the container to the nearest column. When enabled, Masonry will measure the width of the container’s parent element, not the width of the container. This option is ideal for centering Masonry layouts.See Demo: Centered.

isResizable

Boolean

true

Triggers layout logic when browser window is resized.

isRTL

Boolean

false

Enables right-to-left layout for languages like Hebrew and Arabic.See Demo: Right-to-left.

itemSelector

String

Filters item elements to selector. If not set, Masonry defaults to using the child elements of the container.

Recommended to avoid Masonry using any other hidden elements in its layout logic.

$('#container').masonry({ itemSelector: '.box' });

masonry方法Methods

Masonry offers several methods to extend functionality. Masonry’s methods follow the jQuery UI pattern.

$('#container').masonry( 'methodName', [optionalParameters] )

方法名称

说明和示例

appended

.masonry( 'appended', $content, isAnimatedFromBottom )

Triggers layout on item elements that have been appended to the container.

var $boxes = $('

$('#container').append( $boxes ).masonry( 'appended', $boxes );

Setting the isAnimatedFromBottom argument to true will enable the newly appended items to be animated from the bottom, if animation is enabled.

$('#container').append( $boxes ).masonry( 'appended', $boxes, true );

The appended method is ideal to use Masonry with Infinite Scroll, in its callback.

var $container = $('#container');

$container.infinitescroll({

// infinite scroll options...

},

// trigger Masonry as a callback

function( newElements ) {

var $newElems = $( newElements );

$container.masonry( 'appended', $newElems );

}

);

destroy

.masonry( 'destroy' )

Removes Masonry functionality completely. Returns element back to pre-initialized state.

layout

.masonry( 'layout', $items, callback )

Positions specified item elements in layout.

layout will only position specified elements, and those elements will be positioned at the end of layout. Whereas .masonry() will position all items in the Masonry instance.

option

.masonry( 'option', options )

Sets options for plugin instance. Unlike passing options through .masonry(), using the option method will not trigger layout.

// set multiple options

.masonry( 'option', { columnWidth: 120, isAnimated: false } )

reloadItems

.masonry( 'reloadItems' )

Re-collects all item elements in their current order in the DOM.

reload

.masonry( 'reload' )

Convenience method for triggering reloadItems then .masonry(). Useful for prepending or inserting items.

var $boxes = $('

$('#container').prepend( $boxes ).masonry( 'reload' );

remove

.masonry( 'remove', $items )

Removes specified item elements from Masonry instance and the DOM.

remove

加支付宝好友偷能量挖...

2012-11-16Web开发网

masonry ajax瀑布流,瀑布流masonry布局API相关推荐

  1. masonry ajax瀑布流,jquery.masonry瀑布流插件的4个使用步骤

    解释:很简单,就是把下载之后的脚本文件嵌入到你想使用2.瀑布流布局样式代码 .container-fluid { padding: 20px; } .box { margin-bottom: 20px ...

  2. 瀑布流插件|jquery.masonry|使用demo

    Maonsry+Infinite-Scroll实现滚动式分页,网上有很多,这里只说: 瀑布流插件的一个基本使用,附上基本功能的demo <html> <head> <me ...

  3. CSS3与页面布局学习笔记(四)——页面布局大全(负边距、双飞翼、多栏、弹性、流式、瀑布流、响应式布局)

    一.负边距与浮动布局 1.1.负边距 所谓的负边距就是margin取负值的情况,如margin:-100px,margin:-100%.当一个元素与另一个元素margin取负值时将拉近距离.常见的功能 ...

  4. google 流瀑布画廊滑块

    分享一个采用流瀑布网格布局的响应试3d切换画廊,该效果的灵感来源于Chromebook(谷歌笔记本)的入门指南,当你点击流瀑布中的内容元素时便会展示出相应的画廊滑块,你还可以通过键盘左右方向键对滑块内 ...

  5. 类似蘑菇街、迷尚的流瀑布图片展示Demo

    类似蘑菇街.迷尚的流瀑布图片展示Demo 论坛地址:http://www.stay4it.com/ svn下载地址:https://svn.stay4it.com/svn/opensource/bra ...

  6. html5相册瀑布背景,HTML5使用canvas实现代码流瀑布的方法

    HTML5使用canvas实现代码流瀑布的方法 发布时间:2020-06-17 13:35:15 来源:亿速云 阅读:177 作者:鸽子 本篇文章给大家分享HTML5 canvas代码流瀑布的具体代码 ...

  7. html的浮动跟标准流,网页布局的 标准流 浮动流 与 定位流

    一 网页布局方式 #1.什么是网页布局方式 布局可以理解为排版,我们所熟知的文本编辑类工具都有自己的排版方式,比如word,nodpad 等等 而网页的布局方式指的就是浏览器这款工具是如何对网页中的元 ...

  8. css三种定位都脱离文档流了吗,CSS布局之脱离文档流详解——浮动、绝对定位脱离文档流的区别...

    1.代码 (1)示例代码1 CSS布局之脱离文档流详解--浮动.绝对定位脱离文档流的区别 .left { width: 300px; height: 500px; background: red; f ...

  9. 淘宝精准引流:一次布局,长期被动流量

    笔者一直研究各种渠道的引流方法,其中也玩过淘宝引流,个人觉得做淘宝引流效果很好,只是目前做虚拟产品不太好引,做实物产品还是可以长期布局的一个渠道.关于淘宝流量我就不用废话了,谁都知道这是一个大流量平台 ...

  10. 短视频有哪些推广引流方法 ?如何快速布局短视频推广?

    做短视频运营的时候,推广也是日常运营中的一部分,但很多朋友对于如何进行短视频的推广引流还处于一个陌生的阶段,下面给大家分享关于短视频推广引流方法 如何快速布局短视频推广的相关内容. 做品牌营销要知道, ...

最新文章

  1. 卓金武《MATLAB在数学建模中的应用》 第2版
  2. python3版本之间的区别-python3.6与3.4版本的区别是什么?
  3. ML之LiR:基于编程实现简单线性回归案例
  4. java 计算工具类_java精确计算工具类
  5. [转载] Java获取泛型T的类型 T.class
  6. 回答一下这些游戏帧数有关的问题吗?
  7. java算法题走楼梯,程序员必学算法「动态规划」:爬楼梯(完全背包解法)
  8. 008 查看套接字选项是否受支持(获取当前环境下套接字选项默认值)
  9. 严格的别名规则是什么?
  10. 动态表头_Excel制作动态考勤表及周六周日颜色标注
  11. ORACLE数据库异步IO介绍
  12. 6.企业安全建设指南(金融行业安全架构与技术实践) --- 安全培训
  13. win10等系统安装Pads安装步骤及软件卡死问题解决
  14. 用友 NC客户化开发手册
  15. 【非官方】哈工大2022 形式语言与自动机试题解析
  16. PADS软件中,鼠标中键无法放大缩小BUG怎么办?解决办法在这里
  17. 使用单链表制作电子通讯录
  18. 数学思维导图学习方法
  19. 大连考研英语培训百家外语考研英语一如何准备?
  20. 【CVE-2021-1675】Windows Print Spooler RCE

热门文章

  1. java计算机毕业设计基于springboo+vue的毕业生信息招聘求职平台管理系统
  2. mysql只允许指定ip网段_MySQL允许某个IP网段从远程访问的方法
  3. java局部变量赋值给全局变量,干货整理
  4. 【Android学习】Android常用框架
  5. 杭漂5年前端感受-白驹过隙,人生如梦
  6. NYOJ 304 节能(DP)
  7. IDEA 批量修改变量名、批量替换代码快捷键
  8. OPPO快应用小游戏 分包 静态方法报错is not a function问题解决
  9. Mac 让程序坞更丝滑
  10. 哺乳动物-肠道微生物共代谢的印记