-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Row Block: Add support for centering the middle item when the left and right are unequal #45826
Comments
Thanks for opening this @danielbachhuber! There's a PR from @tellthemachines in #45364 that looks like it should allow you to create a layout like that (by setting the first and last elements to "Fill"). If you have the time, it might be worth testing out that PR to check that it does what you're looking for. |
@andrewserong Thanks! Followed up on the PR. |
@andrewserong I don't think #45364 did it for me, unfortunately 😞 Here's my block JSON:
Here's the result: Is there something I'm missing? |
This would be trivial to do with a grid layout: we'd only need 3 equal-sized columns and |
@tellthemachines Awesome! If you want to drop some direction on this issue, someone from my team might pick it up for you. Also, just to be clear: #45364 didn't fix the issue, correct? |
Very interesting! The more we play with these flex-based controls, the more it seems that flex is quite challenging to work with to get the desired result. A +1 for the idea of us looking into a grid layout. For the moment, I think it's possible now with the Row block to get something like the following using Another way that also seems to kinda work is to set the left and right blocks to The unfortunate thing with the flex tools, though, is that setting the left and right blocks to In principle, I think the added controls should enable a variety of creative designs and patterns, and means that we can (kinda) create this pattern, albeit in an unintuitive way. Hopefully it's enough for the moment for creating some patterns that folks need, but I very much agree that having proper Grid layout controls would get us toward a UI that supports users creating these kinds of patterns in an intuitive way, rather than having to kind of hack at the flex values via the Fixed setting. For the moment, though, does messing around with the Fixed control get you closer to the current goal? |
Oh, just adding another one. If you need the Row block to be allowed to wrap to multiple lines, another one to try:
I think that's about the neatest I've been able to get it to work so far from a quick hack around: |
@andrewserong Nice find! That seems to work great:
Things are a bit squashed on mobile: It doesn't look like it's possible to conditionally hide those on mobile, though? #19909 |
No, it currently isn't, with the Row block we only have the toggle to switch |
For sure! Done: #19909 (comment) We can consider this issue solved 🕵️ Thanks for your help working through it, @andrewserong ! |
What problem does this address?
I recently recreated my brochure site using the Site Editor. On the original site, my 'Hand Built' site title was centered, even though the left and right items were unequal in size:
Using the Row Block with 'Space Between Items', the 'Hand Built' site title ends up slightly off center:
It would be great if the Row Block could properly center the middle item, even when the left and right items are unequal in size.
Here's block JSON you can add to the Header template in Twenty Twenty-Three to reproduce the issue:
What is your proposed solution?
Here's some Stack Overflow exploration of the problem: https://stackoverflow.com/questions/32378953/keep-the-middle-item-centered-when-side-items-have-different-widths
While it seems hacky, assigning
flex-grow: 1; flex-basis: 0;
to the left element andflex-grow: 1; flex-basis: 0; text-align: right;
achieves the effect I want:The text was updated successfully, but these errors were encountered: