-moz-column-fill: auto breaks CSS columns in Firef

2019-01-20 12:25发布

I am trying to divide my design into three columns. In Chrome it is working perfectly, but in Firefox it is showing only one column instead of three.

body > div {
  -moz-column-count: 3;
  -moz-column-gap: 10px;
  -moz-column-fill: auto;
  -webkit-column-count: 3;
  -webkit-column-gap: 10px;
  -webkit-column-fill: auto;
  column-count: 3;
  column-gap: 15px;
  column-fill: auto;
}
body > div > div {
  background: #F00;
  height: 400px;
}
body > div > div:nth-child(2n) {
  background: #FF0;
}
<div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>

1条回答
\"骚年 ilove
2楼-- · 2019-01-20 13:27

Either remove the whole -moz-column-fill: auto rule, or change it to -moz-column-fill: balance (The default initial value)

body > div {
  -moz-column-count: 3;
  -moz-column-gap: 10px;
  /*-moz-column-fill: auto;*/
  -webkit-column-count: 3;
  -webkit-column-gap: 10px;
  -webkit-column-fill: auto;
  column-count: 3;
  column-gap: 15px;
  column-fill: auto;
}
body > div > div {
  background: #F00;
  height: 400px;
}
body > div > div:nth-child(2n) {
  background: #FF0;
}
<div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>

That being said, column-fill is still only a Candidate Recommendation, so expect browser behaviour to change.

查看更多
登录 后发表回答