Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid-layout-center-last overwrites breakpoints #9137

Closed
studiobovenkamer opened this issue Aug 25, 2016 · 6 comments
Closed

Grid-layout-center-last overwrites breakpoints #9137

studiobovenkamer opened this issue Aug 25, 2016 · 6 comments
Labels

Comments

@studiobovenkamer
Copy link

How can we reproduce this bug?

  1. Create a grid with 3 or more columns. In my case @include grid-column(6).
  2. For mobile first / below medium: @include grid-layout-center-last(2);
  3. For medium breakpoint: create specific rule @include grid-layout-center-last(3).

What did you expect to happen?
That for medium breakpint an up the rules would not be overwritten by the less specific rule created in step 2.

What happened instead?
The @include grid-layout-center-last(2); that I've created (in step 2) for mobile/small overwrites the medium rule @include grid-layout-center-last(3);

Test case:
This doesn't work

  .team-list {
    @include grid-row();

    .team-member {
      @include grid-column(6);
      @include grid-column-end;
      @include grid-layout-center-last(2);

      @include breakpoint(medium) {
        @include grid-column(4);
        @include grid-column-end;
        @include grid-layout-center-last(3);
      }
  }
}

But this works

  .team-list {
    @include grid-row();

    .team-member {
      @include grid-column(6);
      @include grid-column-end;

//need specific small only or medium and up will be overwritten
      @include breakpoint(small only) {
        @include grid-layout-center-last(2);
      }

      @include breakpoint(medium) {
        @include grid-column(4);
        @include grid-column-end;
        @include grid-layout-center-last(3);
      }
  }
}
@kball
Copy link
Contributor

kball commented Sep 30, 2016

Hmm... @brettsmason @andycochran @JeremyEnglert any of you have an idea what's going on here?

@brettsmason
Copy link
Contributor

@studiobovenkamer I'd like to look at this for you and get it sorted out.
However I'm slightly confused with what you are trying to achieve.

Could you perhaps explain what you wanted to happen on each break point and what actually is happening? Your HTML markup (or an idea of it) would be useful too.

@brettsmason
Copy link
Contributor

@studiobovenkamer Actually I've managed to recreate this, I needed 5 .team-member elements for it to show.
the nth-child set with the small breakpoint is still present on the medium breakpoint. I'm not sure what the best solution is for this, I'll have a think.

@studiobovenkamer
Copy link
Author

@brettsmason let me know is you need any additional info on this. I should have included the HTML.

@andycochran
Copy link
Contributor

Can't you just use grid-col-size() in the medium breakpoint instead of grid-column() again, as it's already a column? You just need to change its size.

If I'm understanding the grid-layout-center-last function correctly, it only centers the last column in the row if it's on a row by itself. So if two .team-members are on one row, they won't be centered.

Hmm… 

@brettsmason
Copy link
Contributor

As this is related to the old legacy float grid and is a bit of an edge case I'm going to go ahead and close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants