[csswg-drafts] [css-flexbox][css-align] Proposal: `justify-items` and `justify-self` to align flex items that are alone on their line (#11244)

benface has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-flexbox][css-align] Proposal: `justify-items` and `justify-self` to align flex items that are alone on their line ==
Ok, I have to say that this is a very rough/raw idea, but the problem it would solve is a real one: there's currently no way to have a flex container with `justify-content: space-between` and `flex-wrap: wrap` _and_ control the horizontal alignment ("justification"?) of the items that end up alone on their line (they are always start-aligned, at least in LTR). [A workaround exists to make them end-aligned](https://stackoverflow.com/a/65423850/3735325), but I couldn't find any to make them center-aligned. What if it was as simple as this?

```css
.flex {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  justify-items: center; /* <-- this currently doesn't work; `justify-items` doesn't do anything in flex layout */
}
```

Or, a more concrete example where we only want to center-align a specific item when it wraps:

```html
<footer style="display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;">
  <nav>Nav content here</nav>
  <div>Social links here</div>
  <p style="justify-self: center; text-align: center;">
    Copyright © 2024 Example Company
  </p>
</footer>
```

Check out that example [on Codepen](https://codepen.io/benface/pen/eYqaoeV), there is currently no way to center-align the copyright notice without using a media query, which is just sad.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11244 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 19 November 2024 20:42:55 UTC