2014-07-22 35 views
0

我有HTML内容总是显示一个div框在顶部:显示的div容器

<html> 
<head> 
<style> 
    .fixedtop1 { position: fixed; top: 5px; left: 0; right: 15px; border: 1px solid black; z-index: 50; padding: 5px} 
    .center250a { width: 350px; margin-left: auto; background-color: #f0f0f0; } 
</style> 
</head> 

<body> 
<div style="height:1000px"> 
    <div style="margin-top:20px" class="fixedtop1 center250a"> 
     <div class="text-style" style="float:left;margin-right:2px"><b>Test:</b></div><div>0</div> 
     <div style="clear:both"></div> 
    </div> 
<p> Just a Test </p> 
<br/> 
</div> 
</body> 
</html> 

的问题是现在position: fixed使用视口随着容器元件,但上面的HTML内容应该集成在iframe中。因此,该示例不使用iframe作为独立的HTML页面,而不使用iframe。

如何解决?对于我来说,除了iframe之外的HTML内容的一些div元素是不可能的,但我可以给iframe标记一些样式属性。

回答

0

iframe及其父母是具有不同浏览上下文的不同文档。 因此,iframe中的元素不会与iframe父级交互,也不能相对于它进行修复。

而不是在div元素中设置固定位置,您需要将其设置在iframe中。

iframe中的元素不需要定位固定。

+0

也许你missunderstood me ...我不想修复iframe的位置,但在iframe中的div容器。请举一个例子。 – sk2212

+0

对不起,也许我不明白你的问题。你想让你的div容器(在一个iframe中)保持固定在页面的顶部,对吗? –

+0

不是在页面的顶部,而是在iframe的顶部,是的。 – sk2212