2012-03-24 100 views
1

我正試圖找到一種方式來居中標識+文本。圖片+文字應該垂直和水平居中。居中標誌(垂直/水平)

我試過幾件事情,現在我有這個網站

<html> 
<head> 
<title>XXX</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<style type="text/css"> 
body { 
    margin:50px 0px; padding:0px; /* Need to set body margin and padding to get consistency between browsers. */ 
    text-align:center; /* Hack for IE5/Win */ 
    } 
#floater {float:left; height:50%; margin-bottom:-120px;} 

#Content { 
    clear:both; 
    width:500px; 
    margin:0px auto; /* Right and left margin widths set to "auto" */ 
    text-align:center; /* Counteract to IE5/Win Hack */ 
    padding:15px; 

    height:240px; 
    position:relative; 
    } 
#text-center{ 
    text-align:center; 
    font-family:Tahoma, Geneva, sans-serif 
    } 
</style> 
</head> 
<body> 

<div id="Content"> 
<img src="logo_small.jpg" width="400" height="143"> 
<p id="text-center">Coming soon</p> 
<p id="text-center">more text</a></p> 
</div> 

</body> 
</html> 

我不知道相關的任何HTML/CSS

+0

在'#text-center'中添加'margin:0px auto;' – uday 2012-03-24 03:00:44

+0

我想將徽標/文本對齊頁面中心(垂直/水平)。你提到的東西去除了2個標籤之間的距離。 – 2012-03-24 03:04:03

回答

0

垂直對齊的內容通常是不好的做法,但可以使用實現 編輯:不得不轉了一些CSS ...

#Content { 
     margin: 0px auto; 
     ... 
     height: 100%; 
     } 
#subContent { 
     position: absolute; 
     top: 50%; 
     height:240px; 
     margin-top: -120px; 
     } 

和創建<div id="subContent"> div內您的內容父div。