use*_*499 3 css iframe positioning
我有一个我需要通过iframe服务的页面,但我只需要显示页面的一部分,而不是整个页面.
我目前的代码是:
<div style="display:block;overflow:hidden;width:500px;height:350px;">
<iframe height="350px" scrolling="no"
src="http://my/page/i/want/to/show/part/of/here/" width="500px"></iframe></div>
Run Code Online (Sandbox Code Playgroud)
我认为最好的选择是在包含div的内部服务iframe,该div具有"overflow:hidden",以便它像一个相框.这是有效的,但问题是我想要显示的内容位于iframe页面的中间,div总是假设0,0是帧的开头.我需要定位iframe,以便div正好在我希望可见的页面部分.
我可以这样做吗?
使用margin-top和margin-left的负值来定位iframe.看下面的代码:
<div style="display:block;overflow:hidden;width:500px;height:350px;">
<iframe style="margin-top:-100px;margin-left:-100px" height="350px" scrolling="no"
src="http://my/page/i/want/to/show/part/of/here/" width="500px"></iframe></div>
Run Code Online (Sandbox Code Playgroud)