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?
Definition of column rule : a rule usually of exact column length used between columns of a page or table.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With