【发布时间】:2015-01-26 11:14:11
【问题描述】:
我正在尝试使用 jquery 修复 tumblr 自定义主题/布局。现在,它正在调用 700px 宽的 iframe。理想情况下,我希望 iframe 宽 540px,高度可变。 (高度取决于网格中垂直图像的数量,但图像宽度保持不变。
window.onload = function() {
$('iframe.photoset').contents().find('.photoset_row').attr("style", "max-width:540px; margin-bottom: -4px; margin-left: 4px; overflow:visible; margin-top:4px ");
$('iframe.photoset').contents().find('.photoset_row').find('img').attr("style", "max-width:540px; height:auto; overflow:visible; margin-left: -6px; ");
$('iframe.photoset').contents().find('.photoset_row_2').find('img').attr("style", "max-width:268px; height: auto; margin-right: 0px; max-height: auto; overflow:visible; margin-left: -6px; ");
$('iframe.photoset').contents().find('.photoset_row_3').find('img').attr("style", "max-width:177px; overflow:visible;margin-right: 0px; margin-left: -6px; ");
基本上这会适当地调整宽度,但不会按比例缩小高度。
因为 iframe 的高度会根据 iframe 中的图像数量而有所不同,所以我无法像使用宽度那样使用绝对 px 值设置高度。我需要它是一个相对高度。
【问题讨论】:
标签: jquery css iframe tumblr tumblr-themes