What calls absolutely be placed in the middle? Container of that is to say issues 4 direction to have span to screen left and right sides, and shrink along with screen volume put relatively changeless perhaps wait for scale to adjust, reside screen from beginning to end among. Absolutely be placed in the middle also has two kinds of cases, the very size of container and opposite size. At the same time a lot of methods can come true, summary rises to be as follows roughly:
1. uses Table character, in Width And Height All Set 100% when, can form container nest inside Td absolutely be placed in the middle, right now can be by nest container very opposite perhaps size. (nonstandard) the attention cannot add statement!
Want to add modal Body below standard mode so, html{height:100%;padding:0;margin:0;}
| It is quotative content below:
<table Width= "100%" Height= "100%" Border= "0" Align= "center" Cellpadding= "0" Cellspacing= "0" > |
2. uses negative edge to be apart from a method, absolutely fixed position makes container opposite screen is absolutely be placed in the middle, right now can be only by nest container very size. (standard) the scale control that loses value and Top Left according to Margin, implementation follows screen absolutely be placed in the middle, container volume changes the parameter that needs readjust Margin Top Left:
| It is quotative content below:
<div Style= "background:#F00; Width:740px; Height:340px; Left:50%; Margin:-170px 0 0 -370px; Position:aBsolute; Top:50%;" > |
What 3. foreigner gives out is additional kind of method, clever use Display:iNline-block; , IE6.0 test is passed. (standard)
Notice 1.height:100% it is crucial: 2.edge and Container concern without nest:
This should be a Bug of IE, the individual is right Display:iNline-block understanding is limited. Edge can regard a fill, container the object that now is be placed in the middle of a fluctuation, those who added setting color to be able to look is clearer, of course you also can add container of any very opposite perhaps size inside Container. But the problem depends on Span is only inside couplet element, interiorly adds a class element is nonstandard logic.
| It is quotative content below: < ! DOCTYPE Html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a Href=" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " Target=" _blank ">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>" > <html Xmlns= "<a Href=" Http://www.w3.org/1999/xhtml " Target=" _blank ">http://www.w3.org/1999/xhtml</a>" > <head> <meta Http-equiv= "Content-Type" Content= "text/html; Charset=gb2312" /><BR> <title> does not have caption documentation </title> <style Type= "text/css" > < ! - - Body {Margin:0; Height:100%;} #edge {Width:0; Height:100%; Display:iNline-block; Vertical-align:mIddle;}#container {Text-align:cEnter; Width:100%; Display:iNline-block; Vertical-align:mIddle;}- - > </style> </head> <body> < ! - - Required For Xhtml1.1 Validation Only- - > <span Id= "edge" ></span><span Id= "container" > <div Style= "width:200px; Height:50px; Background:#F00; Line-height:50px;" > realizes </div> below IE6.0 environment only </span> </body> </html> |
4.CSS behavior Expression controls implementation, nevertheless Expression is IE particular, and cost a source serious, when be being used in great quantities especially. (standard)
Notice crucial definition, do not think Height:100% be trashy inside IE:
Real time gets screen Gao Kuan to be worth, subtract Gao Kuan is worth container to be divided again respectively with 2, get accurate coordinate locates absolutely:
| It is quotative content below: < ! DOCTYPE Html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a Href=" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " Target=" _blank ">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>" > <html Xmlns= "<a Href=" Http://www.w3.org/1999/xhtml " Target=" _blank ">http://www.w3.org/1999/xhtml</a>" ><head><meta Http-equiv= "Content-Type" Content= "text/html; Charset=gb2312" /> <title> does not have caption documentation </title><style Type= "text/css "> < ! - - Html, body {Height:100%;}- - > </style> </head> <body> <div Style= "background:#F00; Position:aBsolute; Left:eXpression((body.clientWidth-50)/2); Top:eXpression((body.clientHeight-50)/2);width:50px;;height:50px;" ></div> </body> </html> |
5.FF1.5 test is passed, absolutely fixed position, the edge is apart from for scale, the 50% opposite size that right now container Gao Kuan is Viewport from beginning to end (standard) :
| It is quotative content below:
<div Style= "position:aBsolute; Top:0; Right:0; Bottom:0; Left:0; Width:50%; Height:50%; Margin:aUto; Background:#F00; Color:wHite; Line-height:20px; Text-align:cEnter;" >FF1.5 test passes </div> |
6.FF1.5 test is passed, absolutely fixed position, locate fluctuation is controlled directly, container of implementation of compulsive edge bureau is opposite size (standard) :
Code: Summary
7.ff1.5IE5 IE6 passes a test
| It is quotative content below:
< ! DOCTYPE Html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > |
8. uses Expression(to be opposite only IE)
| It is quotative content below:
<div Style= "background:bLue;position:aBsolute;left:eXpression((body.clientWidth-50)/2);top:eXpression((body.clientHeight-50)/2);width:50;height:50" ></div> |
Bookmark:Digg Del.icio.us Reddit
