Extra space beneath CSS column layout
Asked Answered
S

1

3

I have a 2 column CSS-only grid which works, however it causes excess space beneath both columns.

screenshot.

If I remove inline-block from each cell the excess space is not so bad however this is needed to prevent the grid wrapping. I presumed the issue was with vertical-align, adding this appears to have made no difference though. Is there any way of preventing this excess space?

.columns {
    -webkit-column-gap: 1.5em;
    -moz-column-gap: 1.5em;
    column-gap: 1.5em;
    -webkit-column-fill: auto;
    -moz-column-fill: auto;
    column-fill: auto;

}

.columns__cell {
    break-inside: avoid-column;
    column-break-inside: avoid;
    display: inline-block;
    vertical-align: top;
    width: 100%;
}

.columns--2 {
    -moz-column-count: 2;
    -webkit-column-count: 2;
    column-count: 2;
}

Structure:

<div class="column column--2">
    <!-- repeated -->
    <div class="widget__item poll column__cell">
        <div class="widget__head clearfix">
            ***
        </div>
        <div class="widget__body">
            ***
        </div>
    </div> 
    <!-- repeated -->
</div>
Sheaves answered 24/9, 2014 at 12:35 Comment(8)
show us some markup, better in a jsfiddleBinetta
Can't you see the extra space under the columns there @LorenzoMarcon? Look at all the whitespace. To the OP, just resize your browser up a bit, the space will go away :-)Cohesive
of course I can see it, but with some markup it'd be easier to help and make some testingBinetta
@Cohesive Resizing the browser makes no differenceSheaves
Ah, being silly doesn't translate to text too well. I keep forgettingCohesive
@Cohesive :) I love British humor, but you're right. Sometimes I just don't get it on text!Binetta
@Cohesive ashamed to be BritishSheaves
The code you added is not enough to replicate the problem. Try making an example on jsfiddle.net that shows the actual problemRadburn
M
1

I would use the float property. .inner is the container in which you nest colLeft and colRight. This should fix your problem.

.inner {
    overflow-x: hidden;
    overflow-y: hidden;
    position: relative;
    margin: 0 auto;
    width: 100%;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
}
.colRight {
    float: left;
    width: 50%;
}
.colLeft {
    padding-right: 10%;
    float: right;
    width: 50%;
}
Mccandless answered 5/2, 2015 at 4:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.