<style>
.outbox {width:auto; height:500px; overflow:hidden; text-align:center; background:#000; }
.divc {<span style="font-family: Arial, Helvetica, sans-serif;">margin-right:auto;</span><span style="font-family: Arial, Helvetica, sans-serif;">margin-leftt</span><span style="font-family: Arial, Helvetica, sans-serif;">:auto;</span><span style="font-family: Arial, Helvetica, sans-serif;"> width:500px; height:100px; background:#505050; }</span>
</style>
<div class="outbox">
<div class="divc"></div>
</div>
要点:
父div中写:
text-align:center;
子div中写:
margin-right:auto;<span style="font-family: Arial, Helvetica, sans-serif;">margin-leftt</span><span style="font-family: Arial, Helvetica, sans-serif;">:auto;</span>
这样子div便相对父div自动居中了