2013-06-02 85 views
0

在我的網站上,無論我做什麼,我似乎都無法將任何內容置於我網站上的任何頁面中。一切都在一邊,或在頁面上隨機的地方。唯一的解決方案是使用絕對定位,它不能很好地工作,非常不方便,因爲我必須手動完成所有工作,因爲每張圖片/表格都需要不同的屬性。下面是該網站的樣子,心就在身邊 - http://i43.tinypic.com/hvb67m.jpgAspx頁面對齊問題

這(表演成員)頁:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 
    <div style=" font-family:'Times New Roman'; " align="center"> 
     <img src= "./Images/ShowMembers.png" alt="ShowMembers" /> 
     <br /> 
     <br /> 
     <br /> 
      <%=str %> 

    </div> 
</asp:Content> 

的CSS樣式表:

body 
{ 
    background: url(/upload/Images/Background.jpg) no-repeat; 
    background-size:100% 100%; 
    background-position:bottom; 

    font-size:18px; 
    font-family: Arial; 
    direction:rtl 
} 
#wrapper{ 
margin:0 auto; 
} 
a 
{ 
    text-decoration:none; 
    color:Blue; 
} 

.noBorder 
{ 
    border-style:none; 
} 

td 
{ 
    vertical-align:central; 
    text-align:center; 
} 

母版沒有什麼相關性。

我會欣賞任何類型的建議,謝謝。

+0

你有沒有嘗試過使用文本對齊:無論你想中心的父元素的中心?唯一一個我看到的文本對齊:center是你的CSS中的td,但是你的代碼中沒有顯示td標籤。 –

+0

該頁仍然看起來一樣... –

+0

你改變了什麼?你想要集中什麼:文本,圖像,div,所有? –

回答

0

試試這個(See the fiddle):

CSS

<style type="text/css"> 
    .center_outer 
    { 
     position: relative; 
     left: 50%; 
     float: left; 
    } 
    .center_inner 
    { 
     position: relative; 
     left: -50%; 
    } 
</style> 

HTML

<div class="center_outer"> 
    <div class="center_inner"> 
       <!-- Put your contents (which needs to be centered) here --!> 
     Whatever contents here get centered. 
    </div> 
</div> 

這將居中div.center_inner內的任何內容。即使漂浮(沒有提到寬度)div s。用這兩個div將div包裝在#Content2內。