Reference: http://bbs.blueidea.com/viewthread.php? Tid = 1906314
Simple Method:
Delete:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Then:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Body>
<Div style = "Background: Blue; position: absolute; left: expression (body. clientWidth-50)/2); top: expression (body. clientHeight-50)/2); width: 50; Height: 50 "> </div>
Complex methods:
<! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en " " Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< HTML xmlns = " Http://www.w3.org/1999/xhtml " >
< Head >
< Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = gb2312 " />
< Title > ::::::::: 16ue.cn ::::::::: </ Title >
< Style >
Body {padding: 0 ; Margin: 0 ;}
Body, HTML {height: 100 % ;}
# Outer {height: 100 % ; Overflow: hidden; position: relative; width: 100 % ; Background: ivory ;}
# Outer [ID] {display: Table; position: Static ;}
# Middle {position: absolute; top: 50 % ;} /* For explorer only */
# Middle [ID] {display: Table - Cell; vertical - Align: middle; position: Static ;}
# Inner {position: relative; top: - 50 % ; Width: 400px; margin: 0 Auto ;} /* For explorer only */
Div. greenborder {border: 1px solid green; Background - Color: ivory ;}
</ Style >
</ Head >
< Body >
< Div ID = " Outer " >
< Div ID = " Middle " >
< Div ID = " Inner " Class = " Greenborder " > Vertical center at unknown height
</ Div >
</ Div >
</ Div >
</ Body >
</ Html >
Expression is resource-consuming. For example:
<Input value = "0" style = "AF: expression (value ++);">