Centering Form On Page

  • Thread starter Thread starter Gerard Seibert
  • Start date Start date
G

Gerard Seibert

I am trying to create a single web page that has a background picture, some text and a subscription form. I have tried using the following to keep the form in the absolute center of the page.

<style type="text/css">
<!--
#form1 { position: absolute;
margin-left: expression((body.clientWidth-form1.offsetWidth)/2);
margin-top: expression((body.clientHeight+form1.offsetHeight)/2);
background-color: #ffffff}
body { background-image: url('blue_lady.gif')}
-->
</style>

I am using the following !doctype statement:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

I then use <div id=form1> "code for my form goes here" </div>

Everything seems all right until I add text to the page. Then the form will stay centered horizontally, but not vertically.

Can someone tell me what I am doing wrong, and how to correct it?

Thanks!

Gerard E. Seibert
(e-mail address removed)

This...this isn't the Matrix? No. It's another training program designed to teach you one thing. If you are not one of us, you are one of them. - Neo and Morpheus, The Matrix
 
A much easier way is to create a table with one cell, center it and put the
form inside it.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------

-----------------------------------
I am trying to create a single web page that has a background picture, some
text and a subscription form. I have tried using the following to keep the
form in the absolute center of the page.

<style type="text/css">
<!--
#form1 { position: absolute;
margin-left:
expression((body.clientWidth-form1.offsetWidth)/2);
margin-top:
expression((body.clientHeight+form1.offsetHeight)/2);
background-color: #ffffff}
body { background-image: url('blue_lady.gif')}
-->
</style>

I am using the following !doctype statement:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

I then use <div id=form1> "code for my form goes here" </div>

Everything seems all right until I add text to the page. Then the form will
stay centered horizontally, but not vertically.

Can someone tell me what I am doing wrong, and how to correct it?

Thanks!

Gerard E. Seibert
(e-mail address removed)

This...this isn't the Matrix? No. It's another training program designed to
teach you one thing. If you are not one of us, you are one of them. - Neo
and Morpheus, The Matrix
 
Back
Top