Skip to content

Commit b3df801

Browse files
committed
fixed support for inline-block
1 parent 5dafa0c commit b3df801

File tree

4 files changed

+43
-33
lines changed

4 files changed

+43
-33
lines changed

jquery.matchHeight-min.js

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery.matchHeight.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,18 @@
5151
if (byRow) {
5252

5353
// must first force an arbitrary equal height so floating elements break evenly
54-
$elements.css({
55-
'display': 'block',
56-
'padding-top': '0',
57-
'padding-bottom': '0',
58-
'border-top-width': '0',
59-
'border-bottom-width': '0',
60-
'height': '100px'
54+
$elements.each(function() {
55+
var $that = $(this),
56+
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';
57+
58+
$that.css({
59+
'display': display,
60+
'padding-top': '0',
61+
'padding-bottom': '0',
62+
'border-top-width': '0',
63+
'border-bottom-width': '0',
64+
'height': '100px'
65+
});
6166
});
6267

6368
// get the array of rows (based on element top position)
@@ -84,10 +89,11 @@
8489

8590
// iterate the row and find the max height
8691
$row.each(function(){
87-
var $that = $(this);
92+
var $that = $(this),
93+
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';
8894

8995
// ensure we get the correct actual height (and not a previously set height value)
90-
$that.css({ 'display': 'block', 'height': '' });
96+
$that.css({ 'display': display, 'height': '' });
9197

9298
// find the max height (including padding, but not margin)
9399
if ($that.outerHeight(false) > maxHeight)

test.css

+7-16
Original file line numberDiff line numberDiff line change
@@ -251,24 +251,15 @@ a, a:link, a:visited, a:active, a:hover {
251251
visibility: hidden;
252252
}
253253

254-
/* test display */
254+
/* test inline-block */
255255

256-
.display-items .item-0 {
257-
display: block;
258-
height: 50px;
259-
}
260-
261-
.display-items .item-1 {
262-
display: inline;
263-
height: 100px;
256+
.inline-block-items {
257+
text-align: center;
264258
}
265259

266-
.display-items .item-2 {
260+
.inline-block-items .item {
267261
display: inline-block;
268-
height: 150px;
269-
}
270-
271-
.display-items .item-3 {
272-
display: table-cell;
273-
height: 200px;
262+
vertical-align: top;
263+
/*width: 20%;*/
264+
float: none;
274265
}

test.html

+16-4
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,30 @@ <h3>data-mh="items-b"</h3>
217217
</div>
218218
</div>
219219

220-
<div class="items-container display-items">
220+
<div class="items-container inline-block-items">
221221
<div class="item item-0">
222-
<p>display: block</p>
222+
<p>display: inline-block</p>
223223
</div>
224224
<div class="item item-1">
225-
<p>display: inline</p>
225+
<p>display: inline-block</p>
226226
</div>
227227
<div class="item item-2">
228228
<p>display: inline-block</p>
229229
</div>
230230
<div class="item item-3">
231-
<p>display: table-cell</p>
231+
<p>display: inline-block</p>
232+
</div>
233+
<div class="item item-4">
234+
<p>display: inline-block</p>
235+
</div>
236+
<div class="item item-5">
237+
<p>display: inline-block</p>
238+
</div>
239+
<div class="item item-6">
240+
<p>display: inline-block</p>
241+
</div>
242+
<div class="item item-7">
243+
<p>display: inline-block</p>
232244
</div>
233245
</div>
234246

0 commit comments

Comments
 (0)