0xAX
0xAX

Reputation: 21817

Change elements position when browser changes size

I have 2 <label> in the right corner of div which located in the center of browser with width/height is 200px/200px. When i change browser size my labels disappears in the right side of browser. How can i make that labels moves to the right side when browser size is changes? I try to make:

.my_label{
  position:absolute;
  right: 20px;
}

But right property is right from the browser window, not from the div.

I need that labels move only when it disappears with browser.

Thank you.

Upvotes: 0

Views: 3906

Answers (1)

Adam Plocher
Adam Plocher

Reputation: 14233

As George stated, make the parent position:relative to have your child element's position be absolute in relation to the containing element (instead of the window).

If you really want to tweak your CSS based on browser size / res, read up on CSS media queries:

https://developer.mozilla.org/en-US/docs/CSS/Media_queries

Upvotes: 3

Related Questions