首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS column-count在fire fox和chrome中有不同的行为。

CSS column-count在fire fox和chrome中有不同的行为。
EN

Stack Overflow用户
提问于 2017-09-05 21:05:27
回答 2查看 278关注 0票数 1

我想像砖头一样展示div。我尝试过使用column-count属性,它在fire fox中工作得很好,但在chrome中却不行。

代码语言:javascript
复制
.container {
   column-count: 3;
   column-gap: 1em;
}
.block {
   width: 100%;
   border: 1px solid;
   display: inline-block;
   text-align: justify;
   margin-bottom: 5px;
}

请参考下面的示例DEMO

我该如何解决这个问题呢?

EN

回答 2

Stack Overflow用户

发布于 2017-09-05 21:32:09

您需要调整容器:

代码语言:javascript
复制
.container
{
    display:flex;
}

将为您提供所需的3列,请参见:

代码语言:javascript
复制
.container {
  column-count: 3;
  display:flex;
}
.block {
  width: 100%;
  border: 1px solid;
  display: inline-block;
  text-align: justify;
  margin-bottom: 5px;
  padding:10px;
}
代码语言:javascript
复制
<div class="container">
  <div class="block">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
  <div class="block">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
  <div class="block">It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</div>
</div>

票数 0
EN

Stack Overflow用户

发布于 2017-09-06 13:05:19

.block {}删除内联块。add -webkit-column-count: 3;/* Chrome,Safari,Opera */用于铬支持行。然后将所有div设置为相等的高度。(或)使用display flex。

代码语言:javascript
复制
.container {
   -webkit-column-count: 3; /* Chrome, Safari, Opera */
 -moz-column-count: 3; /* Firefox */
 column-count: 3;
 -webkit-column-gap:1em;
 -moz-column-gap:1em;
 column-gap:1em;
}
.block {
  width: 100%;
  border: 1px solid;
  text-align: justify;
  margin-bottom: 5px;
}
代码语言:javascript
复制
<div class="container">
  <div class="block">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
  <div class="block">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div>
  <div class="block">It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</div>
</div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46055736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档