2012-11-02 11 views
0

這是我的網頁源:IFRAME對準

<html style="height: 100%"> 
    <head> 
     <link rel="stylesheet" media="screen" href="/public/stylesheets/main.css"> 
     <title></title> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    </head> 
    <body style="height: 100%; margin: 0px"> 
    <table> 
    <tr> 
     <th> 
      <img src="/public/images/logo.jpg" alt="logo" id="logo" /> 
     </th> 
    </tr> 
    </table> 

    <iframe id="testFrame" src="/public/site_down.gif" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100" width="100"> 

    </body> 
</html> 

下面的代碼顯示了在Firefox頁面的中心標誌,但在IE中左對齊。我如何使它獨立於瀏覽器,以便它始終顯示在中心?

<table> 
<tr> 
    <th> 
     <img src="/public/images/logo.jpg" alt="logo" id="logo" /> 
    </th> 
</tr> 
</table> 

iframe代碼左對齊在Firefox和IE中,IE顯示V滾動條,Firefox不。我想使iframe更加靈活,以便客戶端可以刪除任何圖像/ html代碼,以便它始終處於居中狀態,而不顯示任何滾動條。

我的CSS

table 
{ 
    border-width: 0 0 1px 1px; 
    border-spacing: 0; 
    border-collapse: collapse; 
    margin:auto; 
    vertical-align:middle; 
} 

td 
{ 
    margin: 0; 
    padding: 4px; 
    border-width: 1px 1px 0 0; 
} 
+0

表格不應該用於佈局。去班級的後面。 –

+1

@ Diodeus:謝謝你的建議。隨着班級休息,還有其他好的建議嗎?表格部分我瞭解你的評論。尋找有關iframe的任何指導。 – user1361914

回答

0

中心頁面通常像這樣工作:

<body> 
    <div id="wrapper"> 
    ...your side contents... 
    </div> 
</body> 

CSS:

#wrapper { 
    width:960px; 
    margin-left:auto; 
    margin-right:auto; 
} 

同樣的技術可用於中心所有內容,包括圖像和你的Iframe。給它一個類或ID並應用相同的CSS模式。