2014-05-08 26 views
0

我該如何將整個iframe集中?如何居中整個iFrameset?

<html> 
<head> 
<style> 
</style> 
</head> 
<frameset rows="100,*" frameborder="0" border="0" framespacing="0"> 
    <frame name="topNav" src="banner.php"> 
<frameset cols="200,*" frameborder="0" border="0" framespacing="0"> 
    <frame name="menu" src="menu.php" marginheight="0" marginwidth="0" scrolling="auto" noresize> 
    <frame name="content" src="dashboard.php" marginheight="0" marginwidth="0" scrolling="auto" noresize> 

</frameset> 
</frameset> 
</html> 

我試圖<div>和應用text-align:center;但它沒有工作? !

+2

一個'frame'與**'iframe'不相同。您正在使用HTML5中[過時](http://www.w3.org/TR/html5/obsolete.html#frames)的框架/框架集,請停止使用它們。 –

+0

你想使用幀的原因是什麼?我很確定這是沒有必要的,強烈建議不要使用幀... – giorgio

回答

0

替換這些框架集標記,該頁面

<frameset class="center" rows="100,*" frameborder="0" border="0" framespacing="0"> 
<frameset class="center" cols="200,*" frameborder="0" border="0" framespacing="0"> 

Addthese CSS代碼

.center 
{ 
margin-left:auto; 
margin-right:auto; 
width:70%; 
} 
1

您要麼必須在左側和右側創建框架,要麼只是創建一個iframe並避免整個問題(更好的選項)。 frameset已過時,因此您應該避免使用它。

0

聲明div的寬度和應用:

margin:auto; 

margin-left:auto; 
margin-right:auto; 

Working Sample

此外,請避免將來使用frameset!它在HTML5中已過時。

乾杯!