mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.48k stars 25.73k forks source link

Grid for archive-single.html is doing something odd #1489

Closed lsolesen closed 6 years ago

lsolesen commented 6 years ago

Environment informations


Expected behavior

There should be four columns in the first row, but there is only two. All other rows performs nicely.

skaermbillede 2018-01-18 kl 20 20 53

This happens both on splash and archive layout.

Steps to reproduce the behavior

It is reproduced in https://github.com/vih/historie/tree/yearbook --> on the page /yearbooks/

mmistakes commented 6 years ago

This isn't a bug per say. Without getting too much into how CSS works (don't have the time :wink:) you need to split up feature rows from grid items.

The grid items are set to float, and clear every 4th item. What's going on in your example above is the 2 feature rows are being counted as grid items, and on the 2nd grid item (technically the 4 item in the grid archive container) it's clearing it. That's why you see two, then the space.

You'll have to restructure the HTML to get around that.

mmistakes commented 6 years ago

Fire up your web browser's development tools and start inspecting the elements. It'll be easier to see what's going on with the clears.

The grid layout was built for a specific use case, it's not battle tested to be used in this way without some work on your part.

lsolesen commented 6 years ago

Doh! Thanks for the clarification. I should have caught this myself.

jangedoo commented 6 years ago

@lsolesen did you manage to figure out the solution? I also have similar problem. It seems that the first "card" gets a class of grid__item:nth-child(4n+3). From the browser inspector, I changed it to .grid__item:nth-child(4n+1) and everything seemed to work but I'm really not sure where and what to change.

jangedoo commented 6 years ago

I just surrounded the for loop in _layouts/home.html with a div and now everything seems to work fine.

<div>
{% for post in paginator.posts %}
  {% include archive-single.html type="grid" %}
{% endfor %}
</div>