How to make a div always float on the screen in top right corner with CSS?

Sometimes, we want to make a div always float on the screen in top right corner with CSS.

We’ll look at, how to make a div always float on the screen in top right corner with CSS, in this article.

How to make a div always float on the screen in top right corner with CSS?

first we have to use fixed position, To make a div always float on the screen in top right corner with CSS.

For instance, we can write

html,
body {
  height: 100%;
  overflow: auto;
}

body #fixedElement {
  position: fixed;
  bottom: 0;
}

to make the element with ID fixedElement fixed to the screen.

We make it fixed with position: fixed;.

Then we make it stay at the bottom with bottom: 0;.

Conclusion

We use fixed position, To make a div always float on the screen in top right corner with CSS.

Leave a Reply