I am trying to create a bar where items can be placed. The items can be aligned by adding a class to the bar itself, or by adding individual classes to the items. I can't get the second part to work properly. Anyway, here is the code:
.bar {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 80%;
margin: auto;
border: 1px solid black;
padding: 10px;
}
.bar .item {
display: flex;
}
.justify-content-between {
justify-content: space-between !important;
}
.align-self-start {
align-self: flex-start !important;
}
.align-self-end {
align-self: flex-end !important;
}
.align-self-center {
align-self: center !important;
}
<div class="bar">
<span class="item">Item 1</span>
<span class="item">Item 2</span>
<span class="item">Item 3</span>
</div>
<br />
<div class="bar justify-content-between">
<span class="item">Item 1</span>
<span class="item">Item 2</span>
<span class="item">Item 3</span>
</div>
<br />
<div class="bar">
<span class="item align-self-start">Item 1</span>
<span class="item align-self-center">Item 2</span>
<span class="item align-self-end">Item 3</span>
</div>
As you can see, for the third bar, the alignment does not work with the utility classes. What am I doing wrong here? Please note that stretching the items to take up equal widths is not a solution for my use case. Any help is greatly appreciated.