Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Balanced column-fill on chrome

I have a series of inline-block divs displayed in 2 columns using CSS columns.

I want the columns to be balanced (5 items on each side for example).

Without inline-block it works fine. However it sometimes breaks in the middle of one of my elements. Adding inline-block fixes this issue but the columns are no longer balanced in Chrome. In Firefox it works fine.

According to this article (https://css-tricks.com/guide-responsive-friendly-css-columns/#article-header-id-9) it's supposed to be balanced by default unless I set a height. I did not set a height, but I suspect that inline-block leads to the same condition.

The column-fill property is supposed to fix this, but unsupported by Chrome.

Is there a polyfill or workaround I can use?

like image 319
Nathan H Avatar asked Jul 31 '16 08:07

Nathan H


People also ask

What is column rule?

Definition of column rule : a rule usually of exact column length used between columns of a page or table.

What are the CSS properties that are used to manage column breaks?

The break-inside property specifies whether or not a page break, column break, or region break should occur inside the specified element. The break-inside property extends then CSS2 page-break-inside property.

Which of the following is the initial value for the column-fill property?

The column-fill property is specified as one of the keyword values listed below. The initial value is balance so the content will be balanced across the columns.


1 Answers

Try using display: flex instead of display: inline-block. You don't need to use anything else from Flex, but somehow it behaves similarly to inline-block and it works with column-fill: balance in both Chrome and Firefox (in Chrome you may need to use also break-inside: avoid). It may not work for all cases, but I had a similar issue and it worked for me

like image 138
Buszmen Avatar answered Oct 17 '22 00:10

Buszmen