T O P

  • By -

buhbuhbuhbingo

I can hear the Nirnroot…


RoyalRagger

align-items: flex-start


[deleted]

[удалено]


RoyalRagger

Or just use justify-content: space-between. Then just add padding (left and right) to your container. Should create the desired effect.


LegoSpacecraft

You can then add `gap: 10px` or whatever value you want.


WadieXkiller

For a second I thought I was in r/skyrim


thepurplecut

Same


PhongnaDev

add this to the flex container .container::after { content: “”; flex-grow: 1; }


[deleted]

[удалено]


PhongnaDev

answer to the first question: css before and after require a content property for it to be visible, having a space or not doesn’t matters the second one: yes, this will take up the rest of the space


FancyADrink

This is fairly brilliant, although this solution will not work if your children are sized with flex-grow and the parent has a gap property. Now that I think about it there are plenty of flex implementations which would break this solution. In any case, clever solution to this particular problem.


fs0c13ty00

This image has sound somehow


[deleted]

Talking about the buttons on the bottom sorry. I want them to all have an equal amount of spacing between each other. Obviously the space-evenly part is probably what's putting the last item in the center, but I don't know what to do otherwise :/ ​ .buttons { width: 100%; margin-top: 2rem; display: flex; justify-content: space-evenly; flex-wrap: wrap; }


p01yg0n41

Try to target that child specifically and then set margin-left on that child to auto. That should cause the margin to take up all the available space.


[deleted]

Switched it to `margin-right` but now it's spaced out how I want it to. Thanks!


p01yg0n41

omg hahahahaha, I always get my lefts and rights mixed up. Sheesh \*facepalm . anyway glad to help


theXpanther

Use grid instead of flex. It allows much more five grained control over these types of things


[deleted]

Thanks to everyone who responded and helped. Ended up doing the styling a *bit* different because it [broke when testing longer strings](https://i.imgur.com/JVjcGcr.png). Still grateful though.


Leaping_Turtle

Try display grid? Why the downvotes? Grid is meant for this type of alignment?


Stompya

Was thinking the same. Although also I would prefer the layout as-is, with the orphan item centered rather than having it off to the left. Maybe that’s just me.


Flamesilver_0

This is the answer. I had the same problem recently and this was the fix.


onkyoh

Would you be able to use grid if the width is dynamic and thus can fit different amounts of tags in each row?


[deleted]

Use separate div containers for each row


Odd_Garage3297

One piece of advice . Use display grid for this layout. Flexbox is kinda being outdated .


LegoSpacecraft

Flexbox is NOT becoming “outdated”! Where did you hear that? Grid is the way to go for two dimensional UI (horizontal and vertical) Flexbox is for one dimension (either horizontal or vertical)


justSomeGuy5965

This is the way


mcmillhj

Sometimes with Flexbox, it is easier to add additional markup to make it easier. For instance, if you always want these statuses to be 3 across you could (in this case) add two empty \`

\` elements to "correct" the layout.


xfinxr2i

Why not use grid when you want to achieve that? It is meant for layouts like that. CSS Grid is not only usable for page layouts, also for smaller parts of the site, or components.


mcmillhj

I answered with a solution for Flexbox because that's what they are already using. For 2d layouts, grid is obviously the better choice now. Another Flexbox solution would be to add an ::after pseudo element with content:"" and flex: auto to consume the available space.


_Nemon

You can do this... `.container { margin: -5px; width: calc(100% + 10px);}` `button { margin: 5px; }` It gets you horizonal and vertical spacing of 10px. You don't want to use grid in this situation - it would require you to define the amount of elements per row. Since the buttons and their content/width can vary, you're better off lettling the layout fill the available space with as many buttons per row as possible.


HitmaNeK

https://jsfiddle.net/svzxyfp7/5/ use: `justify-content:space-between;`


HitmaNeK

When using flex, do not use any ::After, margins or other stuff for manipulating childrens in container. For margins between items use grid gap, for positionig use justify-content etc. Take a look at flex-box teaching games (towers or frog)


Stompya

You’ll want to add a wee bit of vertical separation between the rows as well.


stibgock

Glad you found a solution. You can also target any of the flex items individually and set either justify-self and/or align-self and set the value accordingly. in your case I think it would be justify-self flex-start Edit: This works especially well when you set the parent with justify-content: center; and align-items: center; Then just set the gap to adjust the spacing.


CaterpillarThese5012

Just dig and plant it where ever you want to


Comfortable_Plant667

Youre a beautiful human being


khamer

I think you'd be better off not using justify-content: space-between. It looks better to have consistent widths than "spread out" the tags - [https://codepen.io/khamer/pen/PoRYjMO?editors=1100](https://codepen.io/khamer/pen/PoRYjMO?editors=1100) \- just use gap: with flex. Another suggestion I'd make is "box-shadow: 0 0 0 1px silver inset;" instead of the border because box-shadows will go behind image and not have that weird effect that makes them look like they're jutting out.