Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

daidr/masonry-css-layout-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

CSS Layout API实现瀑布流

博客 | DEMO

提示

  • 代码在 Edge 99.0.1134.0 测试可用
  • 你需要使用edge/chrome浏览器并在flags中将Experimental Web Platform features启用。

使用方法

  1. 在网页中引入 masonry.js
  2. 准备一个容器元素,添加样式 display: layout(masonry);
  3. 完成🎉

可选的样式

属性 属性值 默认值 说明
--masonry-gap <length-percentage> '20px' 每个子元素间的间距
--masonry-column <number> 4 瀑布流的列数

限制

  • 修改子元素的上下外边距(margin)无法增加间隔
  • 子元素的左右外边距有效,但是不会发生塌陷。你也可以通过使用fixedInlineSize 使得左右外边距无效,但这会导致子元素尺寸完全受脚本控制。

Contributors

AltStyle によって変換されたページ (->オリジナル) /