Using Flexbox, how can you align elements to right?

Experience Level: Junior
Tags: CSSFlexbox

Answer

First you need to define a flex container. You do it by setting a CSS property display to value flex.

The default item flow orientation is horizontal so this is good for our case and we don't need to change it.

To align the item right, we will set a CSS property justify-content to value flex-end.

CSS

div {
  display: flex;
  justify-content: flex-end;
}

Comments

No Comments Yet.
Be the first to tell us what you think.
Flexbox
Flexbox

Are you learning Flexbox ? Try our test we designed to help you progress faster.

Test yourself
25 Flexbox questions that will help you to nail your job interview
25 Flexbox questions that will help you to nail your job interview

Are you learning Flexbox ? Try our test we designed to help you progress faster.

Test yourself