I am currently working on creating a navigation menu that consists of two lists aligned on the same line. It is essential for all items within the lists to have spacing between them, with a maximum of 25px.
An issue with flex-grow: When utilizing flex-grow, the elements tend to expand beyond their width + 25px because there is adequate space available.
An issue with margin-right: In scenarios where the container is smaller in size, the margin-right of 25px remains unchanged, leading to items breaking lines instead of adjusting their margins accordingly.
Potential Solution: Introducing a div element between each item and assigning it properties like flex-grow:1
and max-width:25px
.
Is there an alternative approach without having to introduce additional HTML elements?
Feel free to explore the issue further through the provided codepen: