简体   繁体   English

指定较高的高度不起作用时,如何使iframe更高?

[英]How can I make an iframe taller when specifying a higher height doesn't work?

I have book cover images that are 318x424 , and what I am trying to do is specify an image, and below it a text link. 我的书的封面图像是318x424 ,我要尝试做的是指定一个图像,并在其下方提供一个文本链接。 The initial src is about:blank so that it won't be chewing up user bandwidth if the frame is not displayed by responsive design. 初始src为about:blank因此如果响应式设计未显示该帧,则不会占用用户带宽。

The HTML for the frame is: 框架的HTML为:

<div style="width: 0; text-align: center;">
<iframe id="slideshow" border="0" frameborder="0" frameborder="no"
style="display: none;" width="318" height="725"
src="about:blank"></iframe>
</div>

The JavaScript is: JavaScript是:

--EDIT: Code changed to take advantage of Ian's suggestion-- -编辑:更改代码以利用Ian的建议-

function size_book_cover()
    {
    if (jQuery(window).width() > 1200)
        {
        if (jQuery(window).width() > 1300)
            {
            var width = Math.min(jQuery(window).width() - 1100, 318);
            jQuery('#slideshow').attr('src', '/book_covers.cgi?width=' + width);
            jQuery('#slideshow').css('width',  width + 'px');
            jQuery('#slideshow').css('right', jQuery(window).width() / 8);
            jQuery('#slideshow').css('display', 'block');
            }
        }
    }

What happens instead in both Firefox and Chrome is that the iframe is given a slot the size of one of the pictures; 相反,在Firefox和Chrome中发生的是,为iframe分配了一张图片大小的插槽。 the text link below can be scrolled down to, but is below the fold. 下方的文字链接可以向下滚动,但位于折叠下方。

Any ideas why an iframe should fit the picture snugly when more height has been specified and the content is taller than the picture? 有什么想法为什么当指定了更高的高度并且内容比图片高时,iframe应该紧贴图片吗?

--ADDITIONAL EDIT-- -附加编辑-

One host page containing an iframe is at http://JonathansCorner.com/blacksmiths-forge/ . 包含iframe的一个主机页面位于http://JonathansCorner.com/blacksmiths-forge/

The guest iframe can be seen at http://JonathansCorner.com/book_covers.cgi?width=318 . 可以在http://JonathansCorner.com/book_covers.cgi?width=318上查看来宾iframe。

通过将以下行添加到size_book_cover()解决了该问题:

            jQuery('#slideshow').css('height',  '575px');

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

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