2013-01-18 7 views
0

"위치"스타일과 콘텐츠가있는 div를 가운데에 배치하는 방법은 무엇입니까? , text-align:center (나는 같은 것을 생각)내부에 "위치"스타일과 콘텐츠가있는 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>으로 해봤 및 margin-left:auto; margin-right:auto;

+0

'

'태그는 사용하지 않아도됩니다. 더 이상 사용되지 않습니다. http://stackoverflow.com/questions/1798817/why-is-the-center-tag-deprecated-in-html – Jason

답변

1

당신이 절대 위치가있는 경우, 다음 사용하십시오 : 나는 다음 코드를 left: 50%; margin-left: -200px 변경 패딩을 포함하여 요소 너비의 절반에 해당하는 200px

관련 문제