jquery-match-height icon indicating copy to clipboard operation
jquery-match-height copied to clipboard

Height for the single element in row

Open karki-dennis opened this issue 9 years ago • 6 comments

I have a One item in a row, and it is not giving height to that item. Can we give height to that item? It seems it gives height to the elements if there are only two or more items in the row.

Thanks

karki-dennis avatar Jan 22 '16 10:01 karki-dennis

This is intentional when you're using the byRow option (which is default true), can you should try setting it to false?

liabru avatar Feb 09 '16 19:02 liabru

Hi! I have the same issue, I need the height to be applied even when there is only one element in a set. I am using vertical centering solution inside the element that does not work if the height is not explicitly set.

Tried setting byRow to false but it didn't help.

I understand why you made it like this, but an option to turn this behavior on/off would be awesome.

Thanks for the plugin, it's great!

freshfaceff avatar Jun 08 '16 08:06 freshfaceff

A temporary solution that worked for me was changing the line 127:

from:

if (this.length <= 1 && !opts.target) {

to this:

if (this.length <= 0 && !opts.target) {

freshfaceff avatar Jun 08 '16 09:06 freshfaceff

This feels like something you should just write your own additional code for, since the reason you need an explicit height is not related to matching heights of multiple elements? Or do you have a particular use case where you need both some how?

liabru avatar Jun 08 '16 10:06 liabru

Yeah, it's highly debatable, I can see the pros and cons. Honestly, I don't know if it's worth adding for everyone since I am biased by my particular use case.

Are there any downsides if you would simply change 1to 0 in your code for everyone? I don't see the big picture but you might know better.

I understand there is no point in matching heights when there is only one element in a set but let's say you did that, would it create any problems for people that I can't foresee?

freshfaceff avatar Jun 08 '16 11:06 freshfaceff

+1 for this. I have a set of elements which wrap onto multiple lines based on the screen size. Each contains an image div which has matchHeight called on it, and the position: relative; top:50%; transform:translateY(-50%) trick to center the images vertically.

When items wrap so that there is a single item on a row, that item doesn't have a height set, which breaks the CSS trick.

smerriman avatar Oct 26 '17 01:10 smerriman