How to Align a Div with Fixed Position on the Right Side?

Sometimes, we want to align a div with fixed position on the right side.

In this article, we’ll look at how to align a div with fixed position on the right side.

Align a Div with Fixed Position on the Right Side

To align a div with fixed position on the right side, we set the right CSS property of the div we want to align to the right side.

For instance, we write:

<div class='test'>
  hello world
</div>

and

.test {
  position: fixed;
  right: 20px;
}

to add a div with the class test.

Then in the CSS code, we select the elements with class test, and set the right property on it.

We set it to 20px so that the div is displayed 20px from the right edge of the screen.

Conclusion

To align a div with fixed position on the right side, we set the right CSS property of the div we want to align to the right side.