Workarounds for margin:0 Auto invalidation in CSS
<div class= "Div1" style= "width:100%; height:60px; Float:left; Background: #CCC; " ><div class= "Div2" style= "Width:auto; height:100%; margin:0 Auto; Background: #F00; " >111111111</div></div>
Div1 width is screen width, div2 width varies with content size and centered with Div1, but div2 width I set to auto width or div1 100% width, why this? Study the whole night did not understand, hope to have a master can answer?
To Div2 outside a set of Div3, set div3 for the horizontal center display, that is, text-align:center;div2 set as an inline element, that is, display:inline;
Div defaults to block-level elements, and block-level elements are all on their own, with a width default of 100%.
Running this code under IE8 is not centered except for the body setting Text-align:center are there any other workarounds?
<!doctype html>
Pro-Test IE8 Center No problem
If you want text centered, set the. Tcenter{text-align:center}
margin:0 Auto; is to let the div center, not to let the text center.