简体   繁体   English

为什么我的display:inline-block; 属性从上到下而不是从左到右显示?

[英]Why is my display:inline-block; property displaying in top-to-bottom and not left-to-right?

I am creating a dynamic layout of divs that use display:inline-block, to help fit the content, since it could be different heights. 我正在创建一个使用display:inline-block的div的动态布局,以帮助适应内容,因为它的高度可能不同。

Here is the code I am using, but for some reason, my divs display like 这是我正在使用的代码,但是由于某种原因,我的div显示为

1357
2468

Rather than 而不是

1234
5678

Code I am using: 我正在使用的代码:

article{
 -moz-column-width: 13em;
 -webkit-column-width: 13em;
 -moz-column-gap: 1em;
 -webkit-column-gap: 1em; 

}

section{
 display: inline-block;
 margin:  0.25rem;
 padding:  1rem;
 width:  100%; 
 background:  #efefef;
}

and here is my JSFiddle 这是我的JSFiddle

It's because of the column CSS property, who display elements in "columns" from top to bottom. 这是由于CSS属性column ,该属性从上到下在“列”中显示元素。

To get a horizontal behavior, you can use display: inline-block or use JS plugin such as masonry. 要获得水平行为,可以使用display: inline-block或使用JS插件(如砌体)。

Fiddle with inline-block aligment 内联技巧的小提琴

Have you tried inline-flex ? 您是否尝试过inline-flex I created this jsFiddle 我创建了这个jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的图标从上到下排列而不是在DIV布局中从左向右流动? - Why do my icons line up top-to-bottom instead of flowing left-to-right in a DIV layout? 有没有办法在没有 CSS Flex 的情况下从上到下和从左到右显示 HTML 列表? - Is there a way to display HTML lists top-to-bottom vs left-to-right without CSS Flex? 我该怎么做 <li> 元素从左到右而不是从上到下流动? - How can I make <li> elements flow left-to-right instead of top-to-bottom? 如果我应用display inline-block属性,为什么我的HTML元素从底部开始? - Why, My HTML element is starting from the bottom, if i apply the display inline-block property? 为什么Google Chrome不尊重我的显示:内联块属性? - Why is Google Chrome not respecting my display:inline-block property? div 浮动或向左和顶部显示行内块 - div float or display inline-block to left AND top 为什么这些行内块元素在顶部和底部保留空白? - Why are these inline-block elements keeping whitespace on top and bottom? 从右到左,从上到下的砌体布局与纯 CSS? - Right-to-left, top-to-bottom masonry layout with pure CSS? 为什么这些按钮不会向左浮动或显示内联块? - Why won't these buttons float left or display inline-block? 为什么我的显示:inline-block; 表现得像块? - Why is my display: inline-block; behaving like a block?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM