NetscapeやFirefoxでは、センタリングしたい要素にmargin-left:auto;
とmargin-right:auto;
を指定すればセンタリングされますが、 IEでは更にbody要素などセンタリングしたい要素の親要素にtext-align:center;
を指定する必要があります。
<style type="text/css">
div.centering {
width:100%;
background-color:orange;
margin:0 auto; /* Netscape, Firefox用 */
padding:20px 0;
text-align:center; /* IE用 */
}
div.centering p {
width:80%;
text-align:left;
margin:0 auto; /* Netscape,Firefox用 */
background-color:#ffffcc;
}
</style>
<div class="centering">
<p>NetscapeやFirefoxでは、センタリングしたい要素に<code>margin-left:auto;</code>と<code>margin-right:auto;</code>を指定すればセンタリングされますが、 IEでは更にbody要素などセンタリングしたい要素の親要素に<code>text-align:center;</code>を指定する必要があります。</p>
</div>