Skip to content

Commit

Permalink
Improve row detection when cells contain floating contents
Browse files Browse the repository at this point in the history
The row detection mechanism fixes the height of each cell to 100 pixels.
Cells that have floating contents can in some conditions remain taller
than 100 pixels, causing cells in the same row to be of unequal height.
Adding `overflow: hidden` fixes this problem.
  • Loading branch information
jorrit committed Oct 15, 2015
1 parent 91e50ad commit 8844acb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jquery.matchHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@
'margin-bottom': '0',
'border-top-width': '0',
'border-bottom-width': '0',
'height': '100px'
'height': '100px',
'overflow': 'hidden'
});
});

Expand Down
15 changes: 15 additions & 0 deletions test.css
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,19 @@ a, a:link, a:visited, a:active, a:hover {
display: inline-flex;
vertical-align: top;
float: none;
}

/* test with-float */

.with-float .item-0 {
float: none;
width: auto;
}

.with-float .item-0 div {
display: inline-block;
float: left;
width: 150px;
height: 150px;
background: green;
}
31 changes: 31 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,37 @@ <h3>Target</h3>
</div>
</div>
</div>

<div class="items-container with-float">
<div class="item item-0">
<div>floated</div>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
</div>
<div class="item item-1">
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
</div>
<div class="item item-2">
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
</div>
<div class="item item-3">
<p>some text</p>
</div>
<div class="item item-4">
<p>some text</p>
<p>some text</p>
<p>some text</p>
</div>
</div>
</div>
</body>
</html>

0 comments on commit 8844acb

Please sign in to comment.