Connecting Tech Pros Worldwide Forums | Help | Site Map

Position:absolute - missing scrollbar in IE6

Alexander Fischer
Guest
 
Posts: n/a
#1: Jul 20 '05
Hello everybody,
can someone help me with this problem:
I'm creating a page with a sidebar, and I wanted to create the sidebar as a div
which gets a "position:absolute". The problem: if the sidebar's content is
longer than the main content, my IE6 will not create a vertical scrollbar for
the page, which makes the lower part of the sidebar unreadable.
Take this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Title</title>
<style type="text/css">
body{
background:yellow;
margin:40px;
}
.container{
background:blue;
border:2px solid red;
padding:15px;
position:relative;
}
.maincontent{
background:orange;
border:4px solid yellow;
margin-right:250px;
}
.sidebar{
background:green;
border:4px solid #ccc;
position:absolute;
right:5px;
top:5px;
}
p{
font-size: large;
}
</style>
</head>
<body>
<div class="container">
<div class="maincontent">
<p>main content</p>
</div>
<div class="sidebar">
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
</div>
</div>
</body>
</html>


As you see, I have a "container", and within this container there is the
"maincontent" and the "sidebar". In order to get the sidebar to position in
relation to the container, and not the whole body, I gave the container a simple
"position:relative". As you can try, with IE6 you will not be able to scroll
down to read the whole sidebar. Mozilla behaves as wished.

Is this a IE6 bug?
Is there a workaround?
Am I doing something wrong? Because, if this really was a bug, absolute
positioning would have to be used with a lot of caution - the author would
always have to make sure the absolutely positioned element is not too long....

Thanks for any help,

Alex

Neal
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Position:absolute - missing scrollbar in IE6


On Sat, 19 Jun 2004 20:53:22 GMT, Alexander Fischer <afish@firemail.de>
wrote:
[color=blue]
> Hello everybody,
> can someone help me with this problem:
> I'm creating a page with a sidebar, and I wanted to create the sidebar
> as a div
> which gets a "position:absolute". The problem: if the sidebar's content
> is
> longer than the main content, my IE6 will not create a vertical
> scrollbar for
> the page, which makes the lower part of the sidebar unreadable.[/color]

height: 100%; added to .container fixes this, somehow. Can't say I'm sure
why...
Alexander Fischer
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Position:absolute - missing scrollbar in IE6


Neal <neal413@yahoo.com> typed:
[color=blue]
> On Sat, 19 Jun 2004 20:53:22 GMT, Alexander Fischer
> <afish@firemail.de> wrote:
>[color=green]
>> Hello everybody,
>> can someone help me with this problem:
>> I'm creating a page with a sidebar, and I wanted to create the
>> sidebar as a div
>> which gets a "position:absolute". The problem: if the sidebar's
>> content is
>> longer than the main content, my IE6 will not create a vertical
>> scrollbar for
>> the page, which makes the lower part of the sidebar unreadable.[/color]
>
> height: 100%; added to .container fixes this, somehow. Can't say I'm
> sure why...[/color]

But then, in Opera 5, the container is limited to the browser height :-(

How would you create such a sidebar?
Alex

Alexander Fischer
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Position:absolute - missing scrollbar in IE6


Neal <neal413@yahoo.com> typed:
[color=blue]
> height: 100%; added to .container fixes this, somehow. Can't say I'm
> sure why...[/color]

Now, I tried this with my page and it strangely affected the border and
background of some headings. Try this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>some title</title>
<style type="text/css">
#maincontent{
position: relative;
height:100%;
}
.navigation{
background: blue;
}
#primary{
margin-right:9em;
}
#secondary{
background: #FA0;
position: absolute;
right: 5px;
top: 21px;
width:8em;
}
#maincontent h1{
border:solid 2px #FA0;
background:#124;
color: #FA0;
}
#maincontent h2{
border:solid 2px #124;
background:#FA0;
color: black;
}
</style>
</head>
<body>
<div class="navigation">
<p>
this is the navigation top bar
</p>
</div>
<div id="maincontent">
<div id="primary">
<h1>HEADING 1</h1>
<h2>Heading 2</h2>
<p>Paragraph</p>
<p>Paragraph</p>
<h1>HEADING 1</h1>
<h2>Heading 2</h2>
<p>Paragraph</p>
<p>Paragraph</p>
</div>
<div id="secondary">
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
<p>sidebar</p>
</div>
</div>
</body>
</html>


The main container is called "maincontent", within it there is "primary" (which
takes the normal content) and "secondary" (the sidebar). I now added height=100%
to maincontent, which fixes the scroll problem - but see: the first h1 and h2
lost their background and border!

Isn't this strange? Anyone ever seen this bug before? (IE6)
Thanks and regards,
Alex


Closed Thread