How to place a button right aligned with CSS?

Spread the love

Sometimes, we want to place a button right aligned with CSS.

In this article, we’ll look at how to place a button right aligned with CSS.

How to place a button right aligned with CSS?

To place a button right aligned with CSS, we use flexbox.

For instance, we write

<div style="display: flex; justify-content: flex-end; width: 100%; padding: 0">
  <input type="button" value="Click Me" />
</div>

to make the div a flex container with display: flex;

And we right align its contents with justify-content: flex-end;.

Conclusion

To place a button right aligned with CSS, we use flexbox.

Leave a Reply

Your email address will not be published. Required fields are marked *