如何定位 iframe 内的图像

Iva*_*pić 1 css iframe

如何使用 CSS 将图像定位到 iframe 内?

这不起作用

iframe img {
    height: auto;
    width: 100%;
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

小智 5

尝试jquery这个

$('iframe').contents().find('img').css({width: '100%', 'height': '100%'});
Run Code Online (Sandbox Code Playgroud)

如果 iframe 在页面加载后加载,则将其包装在 jQuery 加载回调中

$('iframe').load(function() {
    $(this).contents().find('img').css({width: '100%', 'height': '100%'});
})
Run Code Online (Sandbox Code Playgroud)