我正在尝试将标头隐藏在iframe中,但是由于某些原因,它无法正常工作。有人可以查看我的代码并帮助我弄清楚为什么标题仍然可见吗?谢谢。
<iframe id="booking_iframe" src="https://bananahostels.com/booking-engine/cacao-hostel" width="100%" height="1500px" frameborder="0" style="border:0;" allowfullscreen=""></iframe>
$('#booking_iframe').load(function() {
$('#booking_iframe').contents().find('.hostel-branding').hide();
}
使用FF开发人员版本提供的工具测量标题的高度,Chrome可能具有类似的功能。
即右键单击>检查元素>右上角的小标尺图标。然后将iframe包裹在css中指定了overflow:hidden;
的另一个div内,那么您所需要做的就是在iframe上设置Css值transform:translateX(-theHeightOftheHeader.);
也许有点hacky,但是由于这是一个外部URL,因此,这似乎是您的最佳选择。