Solved

Footer keeps flying up into the rest of the page

Posted on 2004-03-24
2
212 Views
Last Modified: 2006-11-17
On this page: http://www.ihea.info/pages/results.asp?reg=18 

the div with id of "footer" in the bottom of the page once in a while flies up to the top of the page and rests right under the sidebar. It doesn't happen very often. Keep using the sidebar jump menus and sooner or later it will happen. I am wondering what is wrong with the structure of the page. Is there a way to tell the foot div to stay in the bottom of all the other divs and never overlap them?

This is my CSS for the footer:

#footer {
      display: block;
      position: relative;
      margin: 0% 2% 5px;
      border: solid #fff 1px;
      padding: 0px;
      font-size: .6em;
      color:#666666;
      clear:both;
}
#footer p {
      margin-bottom: -15px;
      margin-left: 20px;
      }
#footer hr {      
      display : none;
      }
0
Comment
Question by:polaatx
2 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 125 total points
ID: 10673264
The problem is that the footer just sits at the bottom of the content, so on short content pages it rides up.  This is the solution:

Do the body tag this way:
<body onload="setBottom(self.screen.availHeight)">

The scripting goes in the head like this:


          <script type="text/javascript">
              <!--
              function setBottom(H)
              {
                   obj=document.getElementById('footer');
                   divoffset=obj.offsetHeight+275;
                   if (obj.offsetTop<H-divoffset)
                   {
                      pos=H-divoffset;
                      obj.style.position='absolute';
                      obj.style.top=pos+'px';
                   }
              }
              // -->
         </script>

If the page is more than full screen the footer will position at the botom of the page.  it the page is less than a full screen the footer will position at the bottom of the screen.  

Cd&
0
 

Author Comment

by:polaatx
ID: 10673738
I see what you mean but I am sure that's not the case becasue it happens regardless of the size of the page.

I ended up taking out the position:relative value out of the #footer and now it doesn't seem to be doing it.

But I will use your code to be sure that the footer stays on the bottom on very short pages. So thank you COBOLdinosaur.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Objects on Same Line 2 38
remove background quote mark from widget 6 67
Background video not displaying in Internet Explorer. 3 37
removing a class in javascript 4 47
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question