...

View Full Version : position right with left margin?



bloody86
06-02-2012, 01: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!

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

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

Maybe I can make myself more clearly with following example:



<html>
<head>
<style type="text/css">

#second{
background-color:yellow;
width:150px;
position:absolute;
right:200px;
}

#first{
margin-left:300px;
}
</style>
</head>

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

</body>

</html>




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!

badwolf
06-02-2012, 01: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;

bloody86
06-03-2012, 03: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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum