"Peter Crom" <pa****@bart.nl> writes:
I am looking for a solution for the following:
I have a frame full of lots o'text with a title on top.
as the reader scrolls through the text, I would like to have the title to
rest in peace at the top of my page.
Sounds like a job for CSS, position:fixed.
I have an intuition that something must be related with:
Try:
---
<style type="text/css" media="screen, print">
#keeping {
color:black;
align:center;
position:fixed;
z-index:10;
top:40px;
}
</style>
---
However, that won't work in IE, because it doesn't understand any more
than rudimentary CSS 2. For its benefit we then add:
---
<!--[if IE]>
<style type="text/css">
#title {position:absolute;}
</style>
<script type="text/javascript">
var root = (document.documentElement && document.compatMode="CSS1Compat")?
document.documentElement : document.body;
root.attachEvent("onscroll",
function(event) {
document.all['title'].style.top =
(root.scrollTop+40)+"px";
});
</script>
<![end if]-->
---
It still fails in IE 4, because it doesn't know conditional comments,
but it's prettier than trying to detect IE the hard (read:impossible)
way.
I do know a considerable lot of css and javascript, but some info seems hard
to get...
Actually, there is a hack for IE 6 that allows you to make fixed elements
(by positioning the absolutely wrt. the html element, and then scrolling
the body element instead). It is prettier than catching up to the scrolling,
but harder to do.
<URL:http://devnull.tagsoup.com/fixed/>
(I recommend against triggering "compatability mode", it is not meant
for new pages. I don't like his updated version for IE 5, because it adds
elements to the HTML to achieve the effect and requires quirks mode).
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'