marcamillion
marcamillion

Reputation: 33775

How do I get a <div> to always be in the top right corner of the browser window regardless of browser size?

I want the following code to always be in top right, regardless of the size (i.e. when the user resizes the browser window, it is still in the same position):

<div id="navbar"><a href="#">Our Blog</a></div>

The CSS that accompanies this as follows:

#navbar {
    position: absolute;
    left: 850px;
    width: 100px;
    padding: 15px 0 0 0;    
}

I would like to do it in CSS and HTML only.

Upvotes: 0

Views: 439

Answers (1)

davidsleeps
davidsleeps

Reputation: 9503

change it from being positioned form the left to be positioned from the right...

#navbar {
  position: absolute;
  right: 0;
  width: 100px;
  padding:  15px 0 0 0;
}

Upvotes: 6

Related Questions