473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

part of page should not scroll with rest

Hi everyone,

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.
I have an intuition that something must be related with:

<STYLE TYPE="text/css" MEDIA="screen, print">
..keeping {
color: black;
align: center;
pos: absolute;
z-index: 10;
top: 40px';
}
</STYLE>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
function set_it_right (me)
{
???
}
</SCRIPT>

<body onscroll="set_it_right(self)">

<div id=title class="keeping">THIS TEXT</div>
lots of text
</body>

But here my knowledge gets confused...

I do know a considerable lot of css and javascript, but some info seems hard
to get...
Please help me.
Jul 20 '05 #1
1 1390
"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.'
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Noozer | last post by:
I am able to place values on forms that load into my webbrowser control, but I'd like to be able to scan the page for data. I know to use the HTMLDocument object. Basically I'm hoping to find an...
10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
1
by: Vangelis Natsios | last post by:
I want to create a page with a scrolling image that will cause different messages to appear on another part of the page (say, another <div>) as the image will scroll. Imagine something like this: ...
2
by: Yaron Cohen | last post by:
Hi, I would like to ask for your help. I am using IE5.5. I have a wide page with horizontal scroll bar. The problem is that I get only 1 page when printing it using "file->print" or...
8
by: deepak datta | last post by:
Hello Gurus, please help suggest how I can remove the space between the top banner image & the rest of the page in: http://www.naturerugs.com/affiliate/default.asp I have tried numerous...
2
by: Tristan Miller | last post by:
Greetings. I have a two-column web layout, where the first column is just the regular body text with a "marign-right" of 16em, and the second column is an "absolute"-positioned div with a width...
2
by: Andy Fish | last post by:
Dear HTML gurus In a single HTML page I have a section at the top that I want to remain in place while the rest of the content scrolls. Most importantly, I don't want the scrollbar to be drawn...
3
by: Cloy | last post by:
I'm currently working on a revised home page for my church. The script loads a date listing into an iframe (in a table cell) at the right side of the page and then scrolls the list to today's...
0
by: dpratt | last post by:
I have two div's next to each other and aligned to the right. Everything is all fine and good until I go to look at the page in 1024px wide resolution and I can't get the page to scroll horizontally...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.