通过设置 iframe 的 src 属性,我在 iframe 中有一个图像:
<iframe src="path/to/my/image.jpg" class="myclass"></iframe>
iframe 具有固定的高度和宽度。我希望该图片的宽度填满 iframe,但它的高度将与宽度成比例,这样用户就可以向下滚动 iframe 以查看图片的其余部分。
我该怎么做?
编辑:JSFiddle 链接 http://jsfiddle.net/2LExA/
最佳答案
我将 iframe 的 src 设置为名为 show_image.php 的页面,并将图像 url 作为查询字符串传递:
<iframe src="show_image.php?src=path/to/image.jpg" class="foobar"></iframe>
然后在 show_image.php 中,我放置了一个 img,其 src 设置为查询字符串,宽度设置为 100%:
<img src="<?php echo $_GET['src']; ?>" style="width:100%" />
完成! 感谢 lukeocom 提示我应该将图像放在单独的页面中。
关于html - iframe 中的样式图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15082459/