Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
Why doesn't my flex container distribute space evenly between items when using `justify-content: space-between`? Pending Review
Asked on Jan 01, 2026
Answer
When using "justify-content: space-between" in a flex container, space is distributed evenly between flex items, but not at the start or end of the container. If it's not working as expected, check for extra margins or padding affecting the layout.
<!-- BEGIN COPY / PASTE -->
<style>
.flex-container {
display: flex;
justify-content: space-between;
border: 1px solid #ccc;
padding: 10px;
}
.flex-item {
padding: 10px;
background-color: #f0f0f0;
}
</style>
<div class="flex-container">
<div class="flex-item">Item 1</div>
<div class="flex-item">Item 2</div>
<div class="flex-item">Item 3</div>
</div>
<!-- END COPY / PASTE -->Additional Comment:
- Ensure there are no extra margins or padding on the flex items that could affect spacing.
- Check if there are any hidden elements or pseudo-elements that might be taking up space.
- Verify that the container has enough space to distribute items as expected.
- Consider using "justify-content: space-around" if you want space on the outer edges as well.
Recommended Links:
