html - Controlling the amount of space in justify-content: space-between - Stack Overflow
why is my justify-content: space-between not working on flex items?
In flexbox, whats the difference between setting justify-content to flex-start and start ?
justify-content: space-between not working when flex-direction is column?
Videos
The justify-content property uses the available space on the line to position flex items.
With justify-content: space-between, all available space is placed between the first and last items, pushing both items to opposite edges of the container.
You wrote:
I was wondering how to justify how much space is allowed in
justify-content: space-betweenfor flexbox.
With space-between in row-direction, you would have to control the width of the flex container. So if you want there to be less space between flex items, then you would need to shorten the width of the container.
Or you could use justify-content: space-around.
However, these solutions are suboptimal.
The right way to go about this would be to use margins.
You wrote:
Currently, my items are spaced but they have way too much space between them I want just a little space between them so they can settle somewhere in the middle in a row.
Use justify-content: center then use margins to space them apart.
My solution was :
- put dummy empty divs in between with a max-height specified
- change space-between to flex-start
- set the content blocks to nogrow
- set the dummy divs to grow
Then the spaces grow up to a max specified.
>> https://codepen.io/coderr11/pen/rNRwVmy
My code pen is above.
header is the parent, where i have placed: display: flex, align-items: center, and justify-content: space-evenly on it.
The child elements of it are .logo-image, .navbar, .btn and .fas - However, .logo-image takes up most of the width as seen by the red background and other flex items are squished to the left and are spaced-evenly. I can define a width on the .logo-image, but why is the default nature of it takes so much space compared to the other flex items?
Thank you