Unbalanced CSS columns in Chrome
Possibly a stupid question, but have you looked into flexbox?
.columns {
display: flex;
flex-flow: row wrap;
align-items: stretch;
-webkit-column-width: 200px;
-moz-column-width: 200px;
column-width: 200px;
-webkit-column-gap: 20px;
-moz-column-gap: 20px;
column-gap: 20px;
width: 600px;
}
.list-group {
display: inline-block;
width: 300px;
}
EDIT Going through unanswered questions and didn't realize how old this is.
CSS multi-column layout of list items doesn't align properly in Chrome
You need each item in the column to be displayed as "inline-block". That will solve your problem without needing to use jQuery.
Additionally, each element can be specified to have width: 100%
in order to get the them to use the full width of the rows.
Here is a working example:
$(document).ready(function() { for( var i = 0; i < 24; i++ ) { $("ul.newslist").append("<li><a href='#'>Item</a></li>"); } $("ul.newslist > li").click(function() { $(this).remove(); })});
ul.newslist { columns: 5; background-color: #ccc; padding: 16px 0; list-style: none;}
ul.newslist > li { display: inline-block; width: 100%; border-top: 1px solid #000;}
ul.newslist > li > a { display: block; padding: 4px; background-color: #f6b; text-decoration: none; color: inherit;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><ul class="newslist"></ul>
chrome and safari render css columns differently when number of items equals number of columns
I sorted this out, at least for Safari vs. Chrome.
Since this only applies when the number of items is equal to the number of columns, and since that number is known, I can apply display: inline-block;
to li
and then override that when the 2nd listing is also the last listing.
In my case, the solution is to add to the CSS:
li {
display: inline-block;
}
li:last-child:nth-child(2) {
display: block;
}
Full CSS:
ul {
moz-column-count:2;
-webkit-column-count:2;
column-count:2;
column-gap: 2em;
}
li {
display: inline-block;
-webkit-margin-before: 0;
-webkit-margin-after: 0;
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
width:100%;
list-style-type:none;
padding: 1em;
box-sizing:border-box;
background-color: #90cdc0;
margin-bottom: 2em;
}
li:last-child:nth-child(2) {
display: block;
}
lists styled with multiple columns breaks in chrome
I was able to fix it with a width on the ul container, I hope it'll help :
.multi ul {
width:500px;
}
See your updated fiddle. You're right on firefox and opera it's working and not on chrome, I tried some other css columns parameters without success.
Related Topics
What Fonts Are Included (I.E. Installed by Default) with Which Operating Systems
Mvc Bundling and Relative CSS Image When Website Is Deployed to an Application
Radio Buttons Show Unwanted White Background in Chrome. Firefox Is Fine
Compass Font-Face Outputs Wrong Path to Font File
Why Does Firefox Treat Helvetica Differently from Chrome
Angularjs: with Ng-Animate & Ng-View, How to Make a 3D Cube Rotation Effect
Media Query About Screen Size Instead of Resolution
How to Make a Flexbox Container That Stretches to Fit Wrapped Items
Dynamic HTML Table with Fixed Header and Fixed First Column
How to Color The Asterix First Character in a P Tag
How to Use CSS3: :Selection Without Changing The Default Color and Background Color
Change CSS Variables Dynamically in Angular
How to Show Red Border at Invalid Input Box After Clicking Submit Button with Angularjs
Install Foundation 5 in Ember-Cli
Overriding CSS on Github Pages Using Slate Theme
The SASS Ampersand and Attribute Selectors