[CSS] Introduction to CSS Columns
Learn how to use CSS columns to quickly lay out fluid columns that are responsive, degrade gracefully and don't require extra markup.
Notes:
column-width
operates likemin-width
, notwidth
. The browser will render as many columns as it can with the width provided. If each column can take up more than the value provided, they will do so.column-span
enables a specific element to ignorecolumn-count
andcolumn-width
. It can be set to an integer to span a certain number of columns, or "all" to span them all. However, this property does not work in Firefox. A workaround could be to move the element (say, a heading) outside of the container with thecolumns
applied to it. That way, it remains outside of the automatic column flow.column-fill
allows you to change the way content flows into columns. By default, it's set to "balance", where content is distributed as much as possible between columns. It can also be set to "auto", but in order to do so, it requires setting a fixed height. This breaks the idea of fluid, responsive layouts, so use it with caution. You'll also need some browser prefixes, so be sure to reference thisbrowser support chart.
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css"> </head> <body> <section> <h class="title">News</div> <nav> <ul> <li><a href="#">World</a></li> <li><a href="#">U.S.</a></li> <li><a href="#">Politics</a></li> <li><a href="#">Business</a></li> <li><a href="#">Sports</a></li> <li><a href="#">Health</a></li> <li><a href="#">Tech</a></li> <li><a href="#">Science</a></li> <li><a href="#">Education</a></li> <li><a href="#">Books</a></li> <li><a href="#">Food</a></li> <li><a href="#">Movies</a></li> <li><a href="#">TV</a></li> <li><a href="#">Automobiles</a></li> <li><a href="#">Real Estate</a></li> <li><a href="#">Jobs</a></li> <li><a href="#">Art & Design</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Subscribe</a></li> <li><a href="#">Archives</a></li> </ul> </nav> </section> </body> </html>
/* Demo only styles */ * { box-sizing: border-box; } body { background: #eee; font-family: 'Karla', sans-serif; font-size: 18px; font-weight: bold; } section { padding: 0 2rem; margin: 0 auto; } ul { list-style: none; padding: 0; margin: 0; } li { padding: 0.5rem 0; } a { padding: 2px 5px; border-radius: 3px; color: #1A4390; } a:hover { text-decoration: none; background-color: #1A3490; color: #FFF; } nav{ columns: 3 150px; column-gap: 3rem; column-rule: 1px dashed #ccc; column-fill: balance; } .title{ column-span: all; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2015-10-02 [Reactive Programming] RxJS dynamic behavior
2015-10-02 [Reactive Programming] Using an event stream of double clicks -- buffer()