I want the items to be align with the black border.
I did space between and didn’t do anything.
.CONTS should be .conts
You may wish to set left and right margins of the boxes to zero and use gap declaration:
margin: 10px 0;
are there any other methods to align or just that?
and also, Why didn’t space between work resulting in doing your method?
@Growly , an alternative to doing this
margin: 10px 0;
would have to set the box-sizing model for all elements. What this line does is includes the border into the sizing of all elements. By default, borders are not included in the width calculations and apply in addition to any specified widths.
I like doing this because it makes calculating widths that much easier. If the element says it’s 600px wide, it’s 600px wide. Not 600px + 10px of border on each side which means it’s actual 620px wide;
The MDN page has a good explanation of the behavior with clickable examples
You could use old-fashioned CSS or use CSS Grid.
justify-content only controls how any spare space is distributed. So
justify-content: space-between does not force there to be space between items. That’s why I have suggested you use the
gap declaration. Your three items in the flex container grow and shrink so there is no spare space.
Put, for example max-width: 200px; in your CSS for your ‘box’ class and you will see
spare-between working. Then change
space-around and you will see the difference.
A word of warning about using
space-between: if one item in the container wraps onto another row, it will appear on the left, not centralised. I understand this current specification of CSS is under review.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.