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 like min-width, not width. 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 ignore column-count and column-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 the columns 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:;
margin:;
} 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;
}

最新文章

  1. Ubuntu Server 设置PPTP客户端连接
  2. zookeeper_service 出错 ........... are only available on JDK 1.5 and higher
  3. 素数筛 uva 543
  4. C#与数据库访问技术总结(十一)之数据阅读器(DataReader)1
  5. Home vs2013
  6. (转)xml序列化
  7. Sublime Text 2中前端必备的常用插件
  8. Assertions
  9. AngularJS 基础教程二:
  10. 从头开始-05.C语言中函数
  11. js数组对象常用方法小结
  12. Markdown 代码测试!
  13. java开发中的链式思维 —— 设计一个链式过滤器
  14. Hive操作语句实例讲解(帮助你了解 桶 bucket)
  15. c#: WebBrowser 禁止在新窗口打开链接
  16. linux c 编程 ------ 头文件及其作用
  17. CodeForce VKcup B
  18. 【Mysql】【Navicat For Mac】Navicat Premium for Mac v12.0.23 + macOS Sierra 10.12.6
  19. SSM整合框架实现ajax校验
  20. 测试之法 —— mock object

热门文章

  1. Java核心 --- 枚举
  2. java Comparable 比较器的使用
  3. 【LeetCode】228 - Summary Ranges
  4. 该不该将变量设为 null ?
  5. 《Linux设备驱动程序》 笔记2
  6. Cocos2d-JS v3.0 alpha 导入 cocostudio的ui配置
  7. 关于python all(itrable)的使用 和列表表达式使用以及复习一下短路效应。
  8. jquery对象和js对象,以及它们的互相转换
  9. 读取proc信息的可扩展实现
  10. 将服务器返回的URL或者网址截取出来特定的字符,然后将字符返回,一般根据返回的字符判断用户是否登录等即时状态