inicio mail me! sindicaci;ón

Realize the summary of problem of absolutely be placed in the middle when CSS makes a webpage

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" >
<tr>
<td Style= "text-align:cEnter;" >
<table Width= "200" Height= "50" Border= "0" Cellpadding= "0" Cellspacing= "0" Bgcolor= "#ef1122" >
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>

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%;" >
</div>

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" >
<html Xmlns= "//www.w3.org/1999/xhtml" >
<head>
<meta Http-equiv= "Content-Type" Content= "text/html; Charset=utf-8" />
<title>Vertical Centering In Valid CSS</title>
<style Type= "text/css" >Body {padding: 0; Margin: 0; Font-size: 75%; Line-height: 140%; Font-family:ARial, helvetica, sans-serif;}Body, html{height: 100%; }A{color: #333;}A:hOver{color: Green;}
#outer {height: 100%; Overflow: Hidden; Position: Relative;width: 100%; Background:iVory; }
#outer[id] {display: Table; Position: Static;}
#middle {position: Absolute; Top: 50%;text-align:cEnter;} /* For Explorer Only*/
#middle[id] {display: Table-cell; Vertical-align: Middle; Position: Static;}
#inner {position: Relative; Top: - 50%;width: 600px;margin: 0 Auto;text-align:lEft;}/*for Explorer Only */Div.greenBorder {border: 1px Solid Green; Background-color: #FFF;}P{margin: 1em;}
</style>
<script Type= "text/javascript" >
/ / < ! [CDATA[Function ToggleContent(name, n) {Var I, t=” , el = Document.getElementById(name);If (! El.origCont) El.origCont = El.innerHTML;
For (i=0;i<n;i ) T = El.origCont;El.innerHTML = T;
}
/ / ] ] >
</script>
</head>
<body>
<div Id= "outer" >
<div Id= "middle" >
<div Id= "inner" Class= "greenBorder" >
<p><a Href= "javascript:tOggleContent(’inner’ , </a> of 1)" > acquiescent length <a Href= "javascript:tOggleContent(’inner’ , </a></p> of page of 2)" > lengthen
<p>1. Open Illustrator, build a file, the picture is rectangular, the picture that should guide than you is a few bigger, white fill. <br />
2. Pitch on rectangle, menu: Effect>Distort&Transform>Zig Zag, set following plans. <br />
3. Menu: Effect>Stylize>Drop Shadow, set following plans. <br />
1. Open Illustrator, build a file, the picture is rectangular, the picture that should guide than you is a few bigger, white fill. <br />
2. Pitch on rectangle, menu: Effect>Distort&Transform>Zig Zag, set following plans. <br />
3. Menu: Effect>Stylize>Drop Shadow, set following plans. </p>
<address Style= "text-align:cEnter; Padding: .5em; Clear: Left;" >
Design By <a Href= "//www.webjx.com" >Webjx</a>This demonstrating that use <a Href= "//www.creativecommons.cn/" > creation is common accredit </a>- - sign and be not commercial use.
</address>
</div>
</div>
</div>
<script Src= "//www.google-analytics.com/urchin.js" Type= "text/javascript" >
</script>
<script Type= "text/javascript" >
_uacct = “UA-152060-1″ ;UrchinTracker();
</script>
<noscript><p>google-analytics</p></noscript>
<script Src= "//www.webjx.com/*/*.js" Type= "text/javascript" ></script>
<noscript><p>stat. </p></noscript>
</body>
</html>

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

Leave a Comment