如何将具有“位置”样式和内容的 div 居中?我有下一个代码:
<div class="block" id="block1" style="position:relative;">
<img />
<div id="temperature" style="position:absolute; top:50px; min-width: 400px; height: 300px; margin: 0 auto"></div>
<div id="tempeControl" style="position:absolute; bottom:0; ">
<button id="minus" style="height: 28px; width:128px;">-</button>
<span id="valueTempe" style="font-weight: bold; color: #fea100; width:28px;">0</span>
<button id="plus" style="height: 28px; width:128px;">+</button>
</div>
</div>
我试过了<center>
,text-align:center
(我认为是一样的),和margin-left:auto; margin-right:auto;