tags:

views:

47

answers:

3

Good Day,

I have a web form against a white background that allows the user to make certain selections. Depending on the selection that the user makes, this form could grow very long lengthwise. (Although I advised against it, the client was adamant). The form works fine and I'm happy.

However, at the bottom of the form is a div footer that is black and has a height of 50 pixels and the width = 100%. Is it possible to use jQuery to always keep it at the bottom of the form no matter what the user chooses?

Here is the page I am referring to.

TIA,

coson

A: 

There is no need to use javascript for this. Just apply following css properties to the footer -

position:absolute;
bottom:0;
Alpesh
You mean `absolute`?
Pekka
@pekka : no the position should be kept `fixed` not `absolute`.
Alpesh
@Alpesh what @Peter says. `fixed` will keep the element positioned on the bottom of the viewport at all times. `absolute` is the solution, if the surrounding container is `position: relative`
Pekka
@Peter Ajtai : yes got that, edited. thanks :)
Alpesh
Also, you'll probably want `padding-bottom:50px` (or greater) on the form so that the footer does not overlap anything.
Tgr
I do not have a surround container, so it will be fixed?
coson
+1  A: 

Instead of using jQuery, can you just get rid of the div and use border-bottom on the css of the form?

shoebox639
A: 

This is a simple CSS problem.

Take a look at your HTML:

                  <!--  V This inline height is your problem -->
<div id="form" style="height:330px">

  <form name="form1" method="post" action="CreditCardInfoMockup.aspx" id="form1">
      ...
  </form>

<div>

...

<div id="footer" ... > ... </div>

Get that inline height assignment out of there!

Your footer is not inside your form. It is outside it. So as the form grows, it overflows the parent div (which cannot change in height). So as the form grows the other divs are not pushed down and out of the way. Instead the form just overflows and covers everything up.

If you let the parent div grow by removing the inline height, then as the form grows, the parent div would grow pushing everything, including the footer down.

Also, the way you use those <br/>s and all the inline CSS is not very elegant. You should read up on CSS.

Peter Ajtai
I'm not using any of those items to make the form longer. The page is: https://lavaggio.net/lavagstaging/charity_page/CreditCardInfoMockup.aspx
coson
oops, I hit the Enter key before I was done. When you change the value in the dropdown, a dynamic form is built.
coson
@coson - Then why would you not keep the `div` last? ---- In other words, then what's the problem? (PS: you can edit your comments) ------- Try editing your question to include the pertinent code.
Peter Ajtai
I do want to keep the div. The problem is if you select 10 items in the dropdown of the Quantity field, the form "cuts" right through the black footer. You're right about the edit, wasn't thinking ;)
coson
ok, got it. that makes sense.
coson
@coson - edited my answer. The form doesn't expand, like it should, since you have hard coded the height of the parent element!!!
Peter Ajtai