HTML layout and typography 2 How to set div always centered relative to the page

Because the browser page big and small, in order to adapt to the width of the browser, allowing for browser always centered div, div left and right margin settings for the auto can achieve this effect.
As shown, a first div is the default, not up and down right and left margins, the second is set to auto margin, drag browser, changing the size of the browser, it can be seen with respect to the second browser always div center .
Test code:

<body>
<div id="body">
<div id="bodyleft" style="background-image:url(images/t1.png);width:790px;height:25px;"></div>
<div id="bodymiddle" style="background-image:url(images/t2.png);width:790px;text-align:center;">LODOP<br>内容<br>内容<br>内容<br>内容<br></div>
<div id="bodyright" style="background-image:url(images/t3.png);width:790px;height:25px;"></div>

<div id="body2">
<div id="bodyleft" style="background-image:url(images/t1.png);width:790px;height:25px;margin:auto;"></div>
<div id="bodymiddle" style="background-image:url(images/t2.png);width:790px;text-align:center;margin:auto;">LODOP<br>Content>br<Content<br>内容<br>内容<br></div>
<div id="bodyright" style="background-image:url(images/t3.png);width:790px;height:25px;margin:auto;"></div>
</div>
</body>

Icon:

Guess you like

Origin www.cnblogs.com/huaxie/p/11321367.html
Recommended