你如何只将网站的某个部分放入iframe? [英] How do you put only a certain section of a website into an iframe?

查看:85
本文介绍了你如何只将网站的某个部分放入iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找只将网站的一小部分放入iframe中。我将如何做到这一点?通常,当我为一个网站设置一个iframe(可以说雅虎)时,它会得到整个网站......可以说我只想要网站的一小部分,我该怎么做?



是否可以在网站的iframe上放置保证金?

我正在寻找在我的网站上放置网站的iframe。 (如果这是有道理的)



预先感谢:D

>在大多数情况下,引用是外部的,您无法控制外部页面。因此,您必须将IFRAME内容滚动到所需的位置。这当然是不可能的。是的,有一些JavaScript的黑客攻击,但它们都是一个糟糕的解决方案,因为滚动只发生在页面加载后。
解决方案



您可以将IFRAME封装到div中,并使用绝对的TOP和LEFT CSS属性滚动DIV内容。



下面是一个例子:

 #my-div 
{
width:400px;
height:200px;
overflow:hidden;
职位:亲属;
}

#my-iframe
{
position:absolute;
top:-100px;剩余
:-100px;
width:1280px;
height:1200px;
}

这里有一个尺寸为400x200px的DIV。

 < div id =my-div现在通过移动内部的IFRAME,您可以将它放置在正确的位置。 > 
< iframe src =http://www.example.comid =my-iframescrolling =no>< / iframe>
< / div>


I'm looking to put only a small part of a website into an iframe. How would I do this? Usually when I set up a iframe for a website (lets say yahoo) it gets the whole website... Lets say I only wanted a small portion of the website, how would I do this?

Is it possible to put margins on an iframe of a website?

I'm looking to put an iframe of a website on my website. (if that makes sense)

Thanks in advance :D

解决方案

In most of the cases the reference is external and you don’t have control over the external page. Thus you’ve to scroll the IFRAME content to the desired position. This of course is impossible. Yeah, there are some JavaScript hacks, but they’re all a bad solution, because the scrolling occurs only after the page is loaded. The Solution

You can wrap the IFRAME into a div and scroll the DIV content using absolute TOP and LEFT CSS properties.

Here’s an example:

#my-div
{
    width    : 400px;
    height   : 200px;
    overflow : hidden;
    position : relative;
}

#my-iframe
{
    position : absolute;
    top      : -100px;
    left     : -100px;
    width    : 1280px;
    height   : 1200px;
}

Here you have one DIV with dimensions 400x200px. Now by moving the IFRAME within it you can position it on the right place.

<div id="my-div">
<iframe src="http://www.example.com" id="my-iframe" scrolling="no"></iframe>
</div>

这篇关于你如何只将网站的某个部分放入iframe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆