-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
XY Grids with grid-margin-x causing horizontal scroll, flush to container and viewport #10297
Comments
Out of curiosity: Did you contain a grid within a grid or is the inner grid contained within a CELL of the outer grid? (Makes a big difference, at least with padded grids.) |
@brettsmason I want to tag you into this |
So this will occur whenever a margin grid hits the edge of the viewport as already identified. This is caused by the negative margin on the grid which is what allows the grid to line up correctly. This was discussed in detail during development - there are basically 2 solutions to this. You can either have margin on left only, so no split gutters. This doesn't cause overflow. However this was deemed to not be a good idea for using with Masonry and a few other reasons. The alternative is to add @kball not sure what to suggest. Can we add a rule to hide overflow on body or can you see any other issues? |
@brettsmason you're right on the nesting, I see that. And margins are margins and nothing can be done about that. The margin gutters are really useful though, I can see them being used to create spaced-out coloured blocks without too much markup. I'm just hoping that with this issue a consistent standardised Foundation approach can be decided (or baked in). Agree that |
If I am not wrong, bootstrap is dealing with it from the very start by setting a max-width on
In case of full width ( fluid ) container, You cannot have I think same can work here. |
I had the same issue with the simple setup:
where the horizontal bar is always present, and:
where it appears when resizing. In this case it can be avoided by adding My suggestion could be to add the margin (or padding) without splitting into left and right , but only to the right side and remove it for the last element. (or, even better, the Susy approach, where one margin (all margins are in %) is always -100% and the other one is calculated... I don't know if this path is doable) |
@jashwant I dont know whether this comment is needed or not but on the container/container-fluid/section part what folks from bootstrap do is simply this twbs/bootstrap#21211 (comment)
This is no rocket science but this is what they do and this is how this should be done! |
If i am understanding For both margin and padding grid we should do,
<div class="grid-container-fixed"> <!-- grid container with fixed layout -->
<div class="grid-x grid-*-*"> <!-- grid row on x-axis, with margin and/or padding grid on x or/and y axis -->
<div class="cell small-6"></div> <!-- .cell.small-6 -->
<div class="cell small-6"></div> <!-- .cell.small-6 -->
</div>
</div>
<div class="grid-container-fluid"> <!-- grid container with fluid layout -->
<div class="grid-x grid-*-*"> <!-- grid row on x-axis, with margin and/or padding grid on x or/and y axis -->
<div class="cell small-6"></div> <!-- .cell.small-6 -->
<div class="cell small-6"></div> <!-- .cell.small-6 -->
</div>
</div>
<div class="grid-x grid-*-*"> <!-- grid row on x-axis, with margin and/or padding grid on x or/and y axis -->
<div class="cell small-6"></div> <!-- .cell.small-6 -->
<div class="cell small-6"></div> <!-- .cell.small-6 -->
</div> And, secondly on #10141 (comment) For Migrating the |
Also Poke 😉 @brettsmason |
I think we are in a different position to Bootstrap as they use a padding only grid (though never used it so could be wrong!). Dealing with a margin grid has its own quirks (but ultimately quite a few plus points too). We have a few scenarios to cover - this CodePen should showcase the common layout requirements, at least for me anyway. Adding a simple @erredeco Its not possible to have the old style self contained @IamManchanda Your summary is pretty much spot on in terms of the use. However the I personally think its clear as is, but then I wrote a lot of it 😉 I think its going to be hard to change class names now though as they are out there in use. Open to suggestions though. @kball Not sure where we go from here to progress this... |
@brettsmason on BEM
|
Why the need for fixed/fluid though? 'grid-container' isn't required if you want a full width grid, only if you want it contained (your fixed). |
@brettsmason see my answer to #10318 there is the reason why you can't add |
I hope you will forgive me for being a bit disputatious, but... to have the same result:
Version 6.4:
Do you see why I feel somehow perplexed?
And have margins instead of paddings, and you'll end up with a bit larger container (1200px instead of 1170) |
@erredeco This will work fine too! <div class="grid-container">
<div class="grid-x grid-padding-x">
<div class="cell">
<h1>Title</h1>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="small-4 cell">Lorem Ipsum</div>
<div class="small-4 cell">Lorem Ipsum</div>
<div class="small-4 cell">Lorem Ipsum</div>
</div>
</div> |
@IamManchanda of course! But for my experience, usually designers want to have an effect like this https://codepen.io/erredeco/pen/NgMjVz so it's better to think of each row as a separate module that contains itself, instead of having a global wrapper :) |
I know it sucks but margin grid needs a |
See #9875 (comment) |
It is just difficult to accept that I need all this just to align the title to the container below :(
|
WIth {Margin Grid} Unfortunately yes!! |
For me best bet would be this above ⏫ #10297 (comment) |
you can spare some div just putting:
But it is a workaround... |
I still think that another way to go could be to use only a right-margin add a class to the last element that resets the margin. (see susy - |
my last 2 cents for tonight (BTW: nice discussion, I appreciate it) I am sure you have already noticed that the padding-grid and the margin-grid are misaligned (See: https://codepen.io/erredeco/pen/pwVreN) |
@erredeco Sorry for the delay in replying! Agreed - great discussion and the feedback is definately valued 😄 I was a long time Susy user and am quite familiar with it. I dont think we are really in a position to make such a potentially huge change to the grid when we have just launched it, though I understand where you are coming from. I think reliance on Regarding the padding/margin grid not aligning - I'd say they have different use cases and generally wouldnt be used together, but I could be completely wrong. Its still very early in the grids life cycle so feedback is still coming in slowly. The benefit of a margin grid is the margin is a "true" gutter, in that its a proper space rather than like the old padding was. I guess we could potentially add a class/way to Having said all that I'm going to look into potentially better ways me could handle this. |
Thank you for your feedback; IMHO there are 2 priorities
|
Your issue will be fixed by adding However, I do think that there should be a padding in |
So I've been taking all the feedback on board and have been experimenting with possible solutions with the grid container. Take a look at this CodePen for what I'm thinking: https://codepen.io/brettsmason/pen/zzLQbm If everyone could take a look and give me feedback that would be appreciated. Then I can put a PR together to solve this. To confirm, this would include removing the current |
@brettsmason just not clear on one thing. Are you suggesting |
@stuartstarrs Yeah exactly that. This has the benefit of working with the margin grid (plus applying negative margin to padding grids by default too) so that both line up correctly as per the comment made by @erredeco. The only other thing I'm not 100% clear on is the What do you think of the approach? |
I think, Everything else is great. Excellent work. |
@jashwant re BEM - sorry that was habbit after having discussed with @IamManchanda (Foundation 7 architecture changes). It will probably be The overflow is a tricky one - if you look at the last demo I have set |
Sorry going off topic, but |
@IamManchanda Yep definitely a good idea. Maybe give examples of possible class naming structures. |
@brettsmason I agree with everything you said originally and more so after seeing all these examples. Since posting this I'm using padding gutters for everything anyway (so far) and as of now I'd probably apply hidden overflow to body as per your original suggestion. With your latest examples and the -full -fluid concepts – I'm trying to think of pros and cons. The biggest pro is that we get to have the use case of margin-grids right up to the sides of the viewport with space around the cells (your Margin grid - fluid container) and without (Margin grid - flush container). I don't know if I'd use these, but, I'd be expecting these to "just work" if I just starting using F6.4 for the first time today. Ideally gutters probably should be margins over paddings as margins are for separating elements and paddings should be internal to elements. Which is why the I thought The cons (con?) is the overflow hidden on the grid container. I think there's going to be lots of people placing things inside a container that need to overflow. I can image a page with rows of containers with elements with negative margins or things that are supposed to overflow not working. Or even just a Foundation Dropdown-menu tucked into the button of a container is going to have all the submenus hidden. I'm really wondering if the grid should be kept exactly as it is and instead some fancy way of more clearly documenting this behavior could found? I think, possibly, my vote is for It's all very subjective, I think, more about what appears to make sense rather than the technical issue I thought it was. |
@brettsmason @kball @ALL others (Please resize the window for responsive) I upvote for |
@stuartstarrs Thanks that was a really helpful response! Completely agree with your thoughts on margin vs padding for gutters - its why we were keen to implement margin in the first place. I also agree on the use of overflow on the container, I dont think we can realistically do it as its going to cause issues down the road like you pointed out, so I will remove this. Therefore I'm thinking we can offer the 3 classes: I definately want to keep the What do you think? @IamManchanda I'm sorry but I really dont see the need for the fixed (bootstraps default |
so, just to recap: |
@erredeco Yep thats correct. A good example of Do they solve your issues? You can now simply place an element within |
Now, I agree that there won't be any need for @erredeco, |
@brettsmason I think that would straight up allow me to use @erredeco the -full is the very very first thing I wanted to do with the XY Grid! Hence this issue. (That said, I wanted to use |
Usecase for flush container if anybody wants one <div class="small-6 cell" style="background-color: #2695FB;"></div>
<div class="small-6 cell" style="background-color: #0079E9;"></div> |
I have put together a PR to address what we have discussed: #10371 |
@brettsmason , Is there any unusual side effect on |
@brettsmason your codepen seems ok; I forked it and did some other tests (https://codepen.io/erredeco/pen/zzmxXo) - the "Padding grid - flush container" case was absent- |
I am not currenty able to make your PR work, sorry |
@brettsmason I think this looks OK. I think having -full and -fluid is slightly easier to grasp and I like how paddings and margins now line up and are completely hot swappable. So the only issue now is the possibility in some cases of having to rely on overflow-x hidden on body. I've been trying to wrack my brain for how that could be a problem and I'm not coming up with anything. The body is the viewport limit in all cases that I can think of. |
Also, in near future, instead of negative margins on |
@jashwant the problem with and |
Going to close this based on #10371 This will go out in a 6.4.2, currently targeting next Monday. |
In the new XY Grid, there may be need to nest grids, with grid-margin-x applied to all.
The margins of the nested grid(s) go out of the bounds of the parent grid, and any grid-container that might be wrapped in.
If flush against the viewport edge, this will result in a horizontal scrollbar.
How to reproduce this bug:
What should happen:
Margins being margins aside, grid-container should probably contain everything
Codepen
https://codepen.io/stuartstarrs/pen/EXQaMB
The text was updated successfully, but these errors were encountered: