简体   繁体   English

iFrame Element的问题没有在容器内重新调整大小

[英]Issue with iFrame Element not re-sizing within container

I am working on a small VA project and I am attempting to pull stats from another website. 我正在研究一个小型VA项目,我试图从其他网站上提取统计数据。 The only way I have been able to find out how to do this, is by using an iFrame with the clip function. 我能够找到如何做到这一点的唯一方法是使用带剪辑功能的iFrame。

Website is: NWGlobalVA.com 网站是: NWGlobalVA.com

Now the Issue I am having is if you go to the main page and re-size the browser in anyway it pushes behind the map element. 现在我遇到的问题是,如果你去主页并重新调整浏览器的大小,它会推动地图元素。 I have tried everything in my knowledge and research to make it re-size with the container. 我已经尝试了我的知识和研究中的所有内容,以便使用容器重新调整大小。

Below is the code I use with the iFrame and CSS to do the clipping. 下面是我使用iFrame和CSS进行剪辑的代码。 Any help would be much more appreciated then you will understand. 任何帮助都会得到更多的赞赏然后你会理解。 I have been trying to do this for a couple days now. 我一直试图这样做几天。 Ideally I would rather just get the information once every 15 minutes and pass it to my database. 理想情况下,我宁愿每15分钟获取一次信息并将其传递给我的数据库。 However on the website none of the tables are defined and I would know how to go about that. 但是在网站上没有定义任何表格,我知道如何去做。

<style>   
.iframeb {   
    position: absolute;   
    left:-384px;   
    right:0px;   
    top: -145px;   
    clip: rect(190px, 625px, 350px, 400px);   
}</style> 


<iframe width="890" height="1900" src="http://fscloud-infotool.de/index.php?page=vasystem&subpage=vadetails&id=10277" class="iframeb" scrolling="no" frameborder="0"></iframe>

The way I deal with iframe size is with javascript (jquery): 我处理iframe大小的方式是用javascript(jquery):

I calculated the original iframe aspect ratio by taking the width/height. 我通过取宽度/高度来计算原始iframe长宽比。 So in your case: 890/1900. 所以在你的情况下:890/1900。

<script>
function size_iFrame()
{
    // If the width and height of the iframe are set 
    // as attributes (<iframe width='890' height='1900'>), 
    // you can have the js calculate it for you.
    // aspect= $('iframe').attr('width') / $('iframe').attr('height');
    aspect= 0.47; 
    $('iframe').css('width', '100%');
    $('iframe').css('height', $('iframe').width() / aspect);
}
$(document).ready(function()
{
    size_iFrame();
    $(window).resize(function()
    {
        size_iFrame();
    });
}
</script>

This will fit the iframe to the width of its container and give it the same aspect ratio as it initially had. 这将使iframe适合其容器的宽度,并使其具有与最初相同的纵横比。

Edit: To answer your question, i'd call it from the ready callback and setup and window resize callback to call every time the screen size changes. 编辑:要回答你的问题,我会从准备好的回调和设置以及窗口调整大小回调中调用它,以便每次屏幕大小更改时调用。 I edited my code above to show this. 我编辑了上面的代码来展示这个。

Edit2: As @mugé points out, you'll also need to remove your iframe css styling for my method to work. Edit2:正如@mugé指出的那样,你还需要删除你的iframe css样式,以便我的方法正常工作。

In responsive design, I assign the iframe a container sized inside the CSS. 在响应式设计中,我为iframe分配了一个在CSS内部调整大小的容器。 For example, 例如,

CSS CSS
.iframe_container { .iframe_container {
display: inline; 显示:内联;
float: left; 向左飘浮;
width: 89%; 宽度:89%; //whatever width you want } //你想要的任何宽度}

You will need to eliminate your .iframeb absolute, right, left positionings, because the container will take care of it all, unless you are talking about the 'List' parameters on top of the map, I would try to use @media to arrange clean lists according to screen sizes for the .iframeb class. 您将需要消除.iframeb绝对,右,左定位,因为容器会处理所有内容,除非您在地图顶部讨论'List'参数,我会尝试使用@media来安排根据.iframeb类的屏幕大小清理列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM