2011-11-04 93 views
0
<div style="text-align:center;"> 
     <select id="sponsorList"></select>&nbsp;<img alt="Loading..." src="../../Img/ajax-loader.gif" id="loader" /> 
     <span style="display:none;" id="selectedSponsorId"></span> 
     <div id="sponsorRowDetails" style="margin-left:auto; margin-right:auto;"> 
      <table> 
       <tbody> 
        <tr> 
         <td>Effective Date: </td> 
         <td><input type="text" id="startDate" /><br /></td> 
        </tr> 
        <tr> 
         <td>End Date: </td> 
         <td><input type="text" id="endDate" /></td> 
        </tr> 
       </tbody> 
      </table> 
     </div> 
    </div> 

的中央使select框是中心,但内sponsorRowDetails中心对齐以及我不能得到的一切。对齐股利

我很喜欢简单的CSS这样的事情。我究竟做错了什么?我也尝试text-align:center;与其他股利,以及直接在第一格保持表。

+0

我有点困惑,你想要达到什么。你想让你桌子的元素的文字中心对齐吗? – doctorless

+0

我只想整个表格的内部是在页面中心对齐,整个表格本身。 – slandau

回答

0

里面你sponsorRowDetails div

<table align="center" style="margin: 0 auto;">

0

给了<table>的宽度,然后应用margin:0 auto;而是执行此操作的表中,将围绕该表在容器中。

0

你的问题是,一个div默认是其父母的宽度的100%。所以在100%的宽度上设置margin: 0 auto;不会做任何事情。如果你想中心它,你需要给div一个宽度,然后你可以应用margin: auto;否则设置text-align: center;sponsorRowDetails