2013-12-14 5 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

고정 대신 '위치 : 절대;'를 사용하십시오. – kleinfreund

답변

0

당신은 왼쪽 추가하여 중심해야 50 %와 iframe을의 절반 폭 마진을 왼쪽 예 :

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

} 

당신에게 top : 50 % 및 margin-top : (iframe 높이의 절반을 뺀 값)을 추가하여 수직으로 가운데 맞추기를 수행 할 수 있습니다. 당신은 아래쪽 또는 "div # iframe-wrapper iframe"위치 지정이 필요하지 않습니다.

관련 문제