Offset a webpage position inside iframe

孤街浪徒 提交于 2019-12-21 15:42:10

问题


I have an iframe pop-up that is supposed to load a form.

The form is part of a larger page and contains some input fields.

In this case, the iframe which loads it (and is limited to about 1000px wide) acts as a "window" into a different page.

Is there a way to align not the iframe but the content itself when it loads in it? I want to load the whole entire html document inside the iframe but with an offset so that the iframe window shows just the fields that would normally be cutoff on a side or on the bottom or something, seeing how the iframe size is limited but the page being displayed is not.


回答1:


There are several ways to do this, you can include an id in the url like: http://somesite.com/yourpage#anchor

This works but if you do not own the site you iframe (like some sort of custom video site with no iframe integration) you can do it via css with an empty offseted div before: http://aldebaranwebdesign.com/blog/how-to-position-a-page-within-an-iframe/

Your CSS:

#outerdiv
{
width:446px;
height:246px;
overflow:hidden;
position:relative;
}

#inneriframe
{
position:absolute;
top:-412px;
left:-318px;
width:1280px;
height:1200px;
}

The html:

<div id='outerdiv'>
<iframe src="http://www.siteto integrate.com/" id='inneriframe' scrolling=no></iframe>
</div>


来源:https://stackoverflow.com/questions/13373884/offset-a-webpage-position-inside-iframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!