R
E
S
O
U
R
C
E
S
       Question Index      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: side or top popup menus, buttons, image rotators, navbars, tons more.
_______________________

Send us your questions and wittiest comments.
_______________________

Report errors on our site.
_______________________

Share your neatest DHTML examples with us; we may publish them.
_______________________


_______________________

      QUESTION INDEX      

Question Index
Browser Insanity
JavaScript
Animation
Buttons and Menus
CSS and HTML


  INFORMATIVE ARTICLES  

Menus-and-Buttons-
Part-I.htm


Menus-and-Buttons-
Part-II.htm


Change-Div-Size-Color-
and-Location-with-the-
W3C-DOM.htm


Bouncing-Ball-Animation-
with-the-W3C-DOM.htm


Style-Changes-with-the-
W3C-DOM.htm


Animation-with-the-
W3C-DOM.htm


Window-Play-and-Some-
Important-DOM-Methods.htm


Using-getElementsByTagName
-and-getElementsByName.htm


The-CSS-Resources-Intro-
Page.htm


Convert-Word-Files-to-HTML-
and-Install-Editor2-to-
Use-Instead-of-NotePad.htm


CSS-Issues.htm

Fixed Positioning Done Right

ALL OF THE FOLLOWING JAVASCRIPT AND CSS ABOUT FIXED POSITIONING SEEMS TO WORK ON ALL PLATFORMS AND JUST ABOUT ALL BROWSERS, AS LONG AS JAVASCRIPT IS TURNED ON.

JDenny of http://dev.jdenny.co.uk/css/ie_fixed.html is the css and javascript genius who came up with the following brilliant CSS and Javascript fixed positioning code and put it on the Web to help those of us that were stumped trying to figure out good fixed positioning codes. Thanks a million JDenny! This has to be the most ingenious DHTML using CSS and Javascript I've ever seen! (Note: The b.gif file in div2 should be left as is, but you do NOT need a b.gif file: it is a dummy name just to keep the code working.)

<style type="text/css">

body {background-image:url(carpet.gif);background-attachment:fixed;} /*background */


#fixed {position: fixed; /*this is the stuff that will NOT scroll when scrolling--it stays fixed */

   border:1px solid black;

   height:660px;

   top: 0px;

   width: 275px;

   left: 1em;

   background-color:white;

   text-align: left;

   margin: 0 25px 0 0;

   padding:10px;

   position: expression("absolute");

   top: expression(eval(document.body.scrollTop)+0);}


#div2 {background: url('b.gif'); /*this is the stuff that WILL scroll when using scrollbar */

   background-attachment: fixed;

   background-position: expression((calculateBgX(this))+"px "+

   (calculateBgY(this))+"px");}


</style>


<SCRIPT LANGUAGE="JavaScript">

<!--


function calculateBgX(oElement) {return document.body.scrollLeft - getOffsetLeft(oElement);}


function calculateBgY(oElement) {return document.body.scrollTop - getOffsetTop(oElement);}


function getOffsetTop(oElement) {var iResult= oElement.offsetTop;

  while (oElement.offsetParent)

  {oElement = oElement.offsetParent;iResult += oElement.offsetTop;}

  return iResult;}


function getOffsetLeft(oElement) {var iResult= oElement.offsetLeft;

  while (oElement.offsetParent)

  {oElement = oElement.offsetParent;iResult += oElement.offsetLeft;}

  return iResult;}


// -->

</script>