2012-01-22 3 views
0

가능한 중복 :
Horizontally and vertically center a pre tag without the use of tables?상대 텍스트 센터링. 수직 및 수평

어떻게해야합니까 수평 및 수직 중심 텍스트 폭을 지정하지 않고?

지금 내가 가진 :

<div class="center"> 
<p id="logo"><span>Coming soon!</span></p> 
</div> 

과 CSS는 다음과 같습니다 텍스트가 서로 다른 폭을 것

span { 
    color:#ff0000; 
    font-size: 14px; 
    font-weight:normal; 
    font-family:sans-serif; 
    border-bottom-color: currentColor; 
    border-bottom-style: dotted; 
    border-bottom-width: 1px; 
    line-height: 1.1; 
} 
.center { 
    width:150px; 
    height:100px; 
    position:absolute; 
    left:50%; 
    top:50%; 
    margin-left:-100px; 
    margin-top:-50px; 
} 

때문에, 나는 또 다른 솔루션이 필요합니다.

답변

1

은 중심 클래스에게 다음과 같은 CSS 보내기 이것은 단지 한 줄의 텍스트에 대한 작동합니다

text-align:center; 
line-height: 100px; 

참고. 예제는 jsFiddle입니다.

관련 문제