2012-09-24 3 views
2

이것은 내가 갖고있는 것이며 중심에 있지 않습니다. 웬일인지 왼쪽으로가는 길입니다. 그것을 위해웹 양식에 텍스트를 가운데에 배치하려면 어떻게합니까?

<div> 
     <asp:Label ID="eagleReplicationManagerLabel" runat="server" CssClass="eagleReplicationManagerLabel"> 
       Eagle Replication Manager 
     </asp:Label> 
    </div> 

CSS :

.eagleReplicationManagerLabel 
{ 
    position: fixed; 
    font-size: 30px; 
    color: #0000FF; 
    text-align: center; 
} 
+0

는 CSS는이 일이 게시물 http://bluerobot.com/web/css/center1.html –

답변

3

display:block을 설정하지만이로 렌더링되기 때문에 그 결과를 볼 수 없었다 내용의 정확한 너비를 차지하는 범위. 그래서 텍스트는 조정할 공간이 충분하지 않았습니다.

.eagleReplicationManagerLabel 
{ 
    position: fixed; 
    font-size: 30px; 
    color: #0000FF; 
    text-align: center; 
    width:500px; 
} 
+1

에서 제안 시도 왜 CSS 스타일의 폭을 증가

을 보여줍니다. 하지만 너비를 100 %로 조정해야했습니다 (그래서 화면 중앙에 위치). thx :) – Testifier

+0

내 솔루션도 이것을 기반으로하지만, 'display : block'에 대해 'position : fixed'를 변경하여 페이지가 아래로 스크롤 될 때 레이블이 멈추지 않도록합니다. – sebagomez

2

text-align: center; 요구 레이블을 포함 <div>에있을 수 있습니다.

0

텍스트는 가운데에 배치되지만 인라인 요소이므로 내부 텍스트만큼 넓습니다.

그렇기 때문에 그것이 가운데에 있는지 알 수 없습니다.

너비를 지정하거나 막히면 가운데 맞춤이 표시됩니다.

.eagleReplicationManagerLabel 
{ 
    position: fixed; 
    font-size: 30px; 
    color: #0000FF; 
    text-align: center; 
    display:block 
} 
0

여기서 문제 asp:Label는 HTML에 span로 렌더링되고 span 요소는 기본적으로 display:inline 스타일된다는 것이다; 결과적으로 CSS 클래스는 아무 것도하지 않습니다. 당신은 DIV의 텍스트를 중심하려면

은 DIV에 text-align:center을 설정하거나 실제로 작동하고 .eagleReplicationManagerLabel

.eagleReplicationManagerLabel 
{ 
    position: fixed; 
    font-size: 30px; 
    color: #0000FF; 
    text-align: center; 
    display:block; 
} 
0
.center{ 
width:200px; 
margin:auto; 
} 

.eagleReplicationManagerLabel 
{ 
position: fixed; 
font-size: 30px; 
color: #0000FF; 
text-align: center; 
} 
<div> 
<div class="center"> 
    <asp:Label Text="Eagle Replication Manager" ID="eagleReplicationManagerLabel1" runat="server" CssClass="eagleReplicationManagerLabel"></asp:Label> 
</div> 

</div> 
관련 문제