This SASS code generates utility classes for flexbox directions, justification, and alignment. The HTML uses these classes to create a flex container with centered items visually arranged in a row.
<div class="flex-row justify-center items-center">
<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="box">Box 3</div>
</div>
$directions: (row, column);
$justify: (start, center, end, between, around);
$align: (start, center, end, stretch);
@each $dir in $directions {
.flex-#{$dir} {
display: flex;
flex-direction: $dir;
}
}
@each $j in $justify {
.justify-#{$j} {
justify-content: map-get((start: flex-start, center: center, end: flex-end, between: space-between, around: space-around), $j);
}
}
@each $a in $align {
.items-#{$a} {
align-items: map-get((start: flex-start, center: center, end: flex-end, stretch: stretch), $a);
}
}
.box {
width: 5rem;
height: 5rem;
background: #4a90e2;
color: white;
display: flex;
justify-content: center;
align-items: center;
margin: 0.5rem;
border-radius: 0.5rem;
}