This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > June 2004 > Position:absolute - missing scrollbar in IE6





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Position:absolute - missing scrollbar in IE6
Alexander Fischer

2004-06-19, 7:15 pm

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

2004-06-19, 7:15 pm

On Sat, 19 Jun 2004 20:53:22 GMT, Alexander Fischer <afish@firemail.de>
wrote:

> 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.


height: 100%; added to .container fixes this, somehow. Can't say I'm sure
why...
Alexander Fischer

2004-06-19, 7:15 pm

Neal <neal413@yahoo.com> typed:

> On Sat, 19 Jun 2004 20:53:22 GMT, Alexander Fischer
> <afish@firemail.de> wrote:
>
>
> height: 100%; added to .container fixes this, somehow. Can't say I'm
> sure why...


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

How would you create such a sidebar?
Alex

Alexander Fischer

2004-06-19, 7:15 pm

Neal <neal413@yahoo.com> typed:

> height: 100%; added to .container fixes this, somehow. Can't say I'm
> sure why...


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


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews