Skip to content
This repository was archived by the owner on Jul 14, 2023. It is now read-only.
This repository was archived by the owner on Jul 14, 2023. It is now read-only.

Edge Case: Neat 2.0 + flexbox + justify-content: center + orphan children #543

Closed
@kgcreative

Description

@kgcreative

Background:
I'm trying to achieve an auto-centering layout. Prior to this, the best way to achieve this was through nth-of-type and class wizardry. Primarily because i'd have to account for how many items exist, how many orphans, etc.

With Neat 2.0 + Flexbox, this is ALMOST solved.

The default neat grid allows for orphans to wrap left, and as I keep adding orphans, they automagically stack very nicely.
neat default

Adding Flexbox, this is even better, since it makes it so staggered grid-column items wrap without weird float issues. It's like adding an automagic clearfix every nth-of-type.
plus flexbox

What I'm trying to achieve, then, is to extend this behavior further with flexbox, by adding justify-content: center to the parent container. This should, in theory, give me the result below.
desired result

However, because neat calculates it's floated position with margin-left, the actual result is this:
bug

My current workaround involves fetching the current custom grid, and adding margin-left and margin-right (half margins) to the the grid-column object, but obviously this gets extremely repetitive and feels very hacky.

The only solution that comes to mind is adding a direction: center to the grid-media() custom map, which would somehow trigger margins to change from margin-left: $gutter; to margin-left: $gutter / 2 and margin-right: $gutter / 2, but that seems to have a lot of ramifications in terms of adding extra complexity to the grid.

thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions