Mis-alignment of last box when wrapped into a single column
See original GitHub issueWrapping Box children, causes last child to be mis-aligned when the page shrinks so they wrap into a single column. Continuing to shrink the window causes the alignment to be corrected, (I think the correction occurs at the small breakpoint).
Expected Behavior
Shrinking a page so that all wrapped children are in a single column, should leave all children properly aligned.
Actual Behavior
The last child in a column appears to be mis-aligned. Evidently, the previous children are center-aligned around the “child + gap”. The last child is center-aligned for the “child” only. Because the previous children include the “gap”, the alignment of the last child is out of place.
URL, screen shot, or Codepen exhibiting the issue
https://codesandbox.io/s/grommet-box-wrap-alignment-t7y8d?file=/src/App.js
Steps to Reproduce
import React from "react";
import { Box, Card, Grommet, grommet, Heading, Paragraph } from "grommet";
import { hpe } from "grommet-theme-hpe";
const theme = hpe;
const cardWidth = "medium"; // medium or large (small cards do not wrap for some reason)
const cardHeight = "small"; // small, medium or large
export default function App() {
return (
<Grommet theme={theme}>
<Heading>Wrap Alignment</Heading>
<Paragraph margin="small">
<b>Instructions</b>: Shrink window width until all three cards are in a
column. Notice that the alignment of the last card is offset by the "gap
width".
<br />
<br />
<i>
NOTE 1: This problem only shows up with "medium" and "large" cards.
Small sized cards do not wrap for some reason.
</i><br /><br />
NOTE 2: Alignment is corrected as screen width reaches the small breakpoint.
</Paragraph>
{/* wrap allows one-card at a time to wrap to next row */}
<Box align="center">
<Box direction="row-responsive" gap="medium" justify="center" wrap>
<Card
border
width={cardWidth}
height={cardHeight}
margin={{ bottom: "small" }} // for wrapped cards
></Card>
<Card
border
width={cardWidth}
height={cardHeight}
margin={{ bottom: "small" }} // for wrapped cards
/>
<Card
border
width={cardWidth}
height={cardHeight}
margin={{ bottom: "small" }} // for wrapped cards
/>
</Box>
</Box>
</Grommet>
);
}
Your Environment
- Grommet version: v2.15.2 (tested with both grommet-theme-hpe and grommet)
- Browser Name and version: Chrome
- Operating System and version (desktop or mobile): Windows
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Fix data that is cut off in cells - Microsoft Support
Fix data that is cut off in cells by having the text wrap automatically, changing the alignment, decreasing the font size to fit...
Read more >Flexbox wrap - different alignment for last row - Stack Overflow
In the flexbox model, "align" refers to alignment along the cross-axis (i.e. in a conventional sense of a "row" layout direction, ...
Read more >Mastering wrapping of flex items - CSS: Cascading Style Sheets
Flexbox was designed as a single dimensional layout, meaning that it deals with laying out items as a row or as a column...
Read more >Everything You Need To Know About Alignment In Flexbox
The answer is that the fallback alignment of flex-start is used and your single item will align to the start of the flex...
Read more >How to change alignment in Excel, justify, distribute and fill cells
Change alignment with custom number format; Align a column of numbers by decimal point; Align numbers in a column by a specific character ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Excellent, thank you Eric. That fixed it. Mind the gap 😄.
In my case, previously, I used
gap="small"
in the containing Box. I removed that and to the contained Cards I addedmargin={{ right: 'small' }}
and all Cards line up.Yes, this one can be closed.
Cheers, Matt.
On Wed, 21 Oct 2020, 1:51 pm Shimi, notifications@github.com wrote: