2013-12-14 25 views
0

我的UI中有iframe元素存在問題。當我調整屏幕大小(縮小尺寸)並開始使用水平滾動滾動時,它不會滾動到iframe,但iframe保持在同一固定位置,並且不可能看到它。如何使iframe在主窗口水平滾動時更改其位置

Example

和HTML:

<div id="top-element">Some div that has greater width than the inner div</div> 
<div id="iframe-wrapper"> 
    <iframe src="http://www.apple.com/" scrolling="auto"></iframe> 
</div> 
+2

使用'position:absolute;'而不是固定的。 – kleinfreund

回答

0

您必須通過添加左心吧:50%和利潤率左I幀的半寬度例如:

div#iframe-wrapper { 
    position: fixed; 
    left: 50%; 
    margin-left:-150px; /* this must be the half of the iframe's width */ 

} 

你可以通過添加top:50%和margin-top(減去iframes高度的一半)來執行垂直居中。您不需要底部或「div#iframe-wrapper iframe」關於定位