2015-10-14 87 views
0

我有一個簡單的問題,但我剛開始學習HTML/CSS。 我想在全屏幕中顯示一個iframe,我可以這樣做,但我也想在其上顯示我的導航菜單。在iframe上顯示導航

我的HTML看起來像這樣:

<body> 
    <nav> 
     (menu items) 
    </nav> 
    <iframe src="http://xx.xx.xx.xx/" style="border: 0; width: 100%; height: 100%; display: block; position: absolute; left: 0px; top: 0px;"/> 
</body> 

的問題是,我只能在iframe中加載之前看到的導航菜單,然後消失的iframe下方。

我怎麼能顯示它在頂部? (像這樣:http://puu.sh/kK6Eu/e55531777f.png

謝謝。 (對不起,我的英文,我是法國人)

回答

0

使用下面的代碼

<body> 
    <nav style="position: relative; z-index: 2;"> 
     Hello 
    </nav> 
    <iframe src="http://xx.xx.xx.xx" style="border: 0; width: 100%; height: 100%; display: block; position: absolute; left: 0px; top: 0px;"/> 
</body> 
+0

如果我刪除位置:絕對;導航欄顯示在iframe – BriceFW

+0

上方/之前,您希望導航欄位於iframe上方並位於頂部位置? –

+0

是像這樣的畫面:http://puu.sh/kK6Eu/e55531777f.png – BriceFW

1

您需要在其CSS屬性中更改nav元素的Z-index。 Z-index較高意味着更高的元素

nav{ 
    z-index: 2 
} 

iframe{ 
    z-index: 1 
} 
+0

謝謝,用添加位置的屬性,它工作正常! – BriceFW