When using column-count
in a wrapper, and the containers in the wrapper have border-radius
applied, and content in the container is overflowing, the content completely disappears in all the columns, except the first one.
Here is my example: https://jsfiddle.net/f4nd7tta/
The red semi-circle is only visible in the first column, why?
#main_wrap{ width:100%; border:solid 1px black; -moz-column-count: 3; -webkit-column-count: 3; column-count: 3; } #main_wrap > div{ border-radius:5px; overflow:hidden; position:relative; -moz-column-break-inside: avoid; -webkit-column-break-inside: avoid; column-break-inside: avoid; width:70%; height:300px; border:solid 2px grey; margin:2px; } #main_wrap > div > div{ position:absolute; background:red; border-radius:40px; width:40px; height:40px; right:-20px; top:0; }
<div id="main_wrap"> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> <div><div></div></div> </div>
The column-count will act as the maximum number of columns, while the column-width will dictate the minimum width for each column. By pulling these properties together, the multi-column layout will automatically break down into a single column at narrow browser widths without the need of media queries or other rules.
Multiple-column layout, usually referred to as multicol, is a specification for laying out content into a set of column boxes much like columns in a newspaper. This guide explains how the specification works with some common use case examples.
With CSS columns you can create a print-inspired layout with little added markup that can adapt beyond a fixed canvas. A supported browser will make calculations to wrap and balance content into tidy columns. If you're already working with a fluid layout, the columns will reflow automatically.
The columns property in CSS sets the number and width of columns in a single declaration. It is a shorthand property that can take several values at a time. It is used to set both column-count and column-width properties at the same time.
I honestly have no idea why this happens, I am looking the docs if they have specified this behavior, I want to check whether its intentional or it's a bug. For now I am using
-webkit-transform: translateX(0); -moz-transform: translateX(0); transform: translateX(0);
And it works... So add the above properties in #main_wrap > div
and I think if you are ruling out the vendor prefixes than transform: translateX(0);
is sufficient.
Demo
Ok, I think it's a bug :
Issue 84030 : CSS 3 Column bug (overflow: hidden like functionality where it shouldn't)
The absolute positioned elements are clipped as if there is an overflow: hidden applied to the box. However, applying overflow: visible or any other rule does not fix the problem
I thought more over this, as I suggested the first solution which I randomly inserted the properties and it worked, there is also a way where you can legally do what you are doing by using a clip
property and you won't need overflow: hidden;
anymore..
#main_wrap > div > div{ position:absolute; background:red; border-radius:40px; width:40px; height:40px; right:-20px; top:0; clip: rect(0px,20px,40px,0px); }
Demo 2 (Clip Demo)
I spent quite a bit of time investigating this problem and found the suggestion to add the CSS property will-change: transform;
to the items inside the column layout. For example:
<div class="container"> <div class="item"> <!-- Things with overflowing content --> </div> <div class="item"> <!-- Things with overflowing content --> </div> <div class="item"> <!-- Things with overflowing content --> </div> </div> <style> .container { columns: auto 5; column-gap: 0; margin: -16px; } .items { break-inside: avoid; padding: 16px; page-break-inside: avoid; will-change: transform; } </style>
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