Aligning items in flex
needs to be handled using justify-content
or align-items
You need to use justify-content
in your code:
.row {
display: flex;
justify-content: flex-end;
}
When you use display:flex
for an element it has a default flex-direction
with value of row
. it means your inner elements will be placed in a row. This direction(row) is your main direction. justify-content
will specify the location of your items in their main direction.
The value of justify-content
can be flex-start
, flex-end
, etc. You need to set it to flex-end
which in your situation means right side.
I highly recommend you to read the below link for more information:
justify-content:
This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line. A Complete Guide to Flexbox