it seems like absolutly positioned div is affected by layout

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

it seems like absolutly positioned div is affected by layout

Post by newmember »

i pasted here some ready to use code
just save it as html,run and see the problem and the question

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Strange problem</title>
<style type="text/css">

#leftcol&#123;
position:absolute;left:0px;
width:30px;height:100%;
background-color:#0f0;
&#125;

#middle&#123;
margin-left:35px;
background-color:#00f;
&#125;

#rightcol&#123;
position:absolute;right:0px;
width:30px;height:100%;
background-color:#0f0;
&#125;

#mainbody&#123;
height:300px;width:100%;
position:relative;
background-color:#f00;
&#125;
</style>
</head>
<body>
<div id="mainbody">
<div id="leftcol"></div>
<div id="middle">the greeen div on the right for some reason moves down/up<br /> as i change #middle's height...but it is absolutly positioned!!<br />Do you know what causes it to move??<br />Thank you</div>
<div id="rightcol"></div>
</body>
</html>
thank you
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

add top:0px to the styles of the left and right columns.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

thanks a l :D t...
(such a stupid err :oops: r)
Post Reply