View Full Version : position right with left margin?

06-02-2012, 02:20 AM
Hi there to everyone!

What exactly I need is, for example, a div element to have right position, lets say about, 300px and maintain that position until it's left position reach 200px and stops there while resizing browser window!

I tried with margins, padding, everything but no luck!

Although I can achieve this with javascript, I would like to avoid javasript for positioning elements because of cross browser compatibility!

Any help would be appreciated, thanks in advance!

06-02-2012, 02:24 AM
You might be able to do it using CSS media queries that check the browser width.

06-02-2012, 01:22 PM
OK, I'm sorry if I not make my words clear enough!

Maybe I can make myself more clearly with following example:

<style type="text/css">



<div id="first">
<div id="second">This div needs to stop at 300px from left </div>



I need "second" div to stop on 300px from left while decrease browser window width.

As you can see in example I was tried with margin-left but that is just not working!

Thanks again for trying to help me!

06-02-2012, 02:40 PM
If you want your divs to decrease or increase with different screen widths you should use %'s instead of exact pixel width. This will help ensure that your div's wont be pushed down in a smaller screen

Also you should try floating your div if your having issues with them sitting properly. ie: float:left;

06-03-2012, 04:56 PM
Why is so hard to understand what i want to accomplish!?

I guess I will have to do it with javascript! :(

Float property is just not helping here!