How can I target image inside iframe with CSS?
This doesn't work
iframe img {
height: auto;
width: 100%;
}
How can I target image inside iframe with CSS?
This doesn't work
iframe img {
height: auto;
width: 100%;
}
try jquery for this
$('iframe').contents().find('img').css({width: '100%', 'height': '100%'});
wrap this in jQuery load callback if iframe loads later after the page loaded
$('iframe').load(function() {
$(this).contents().find('img').css({width: '100%', 'height': '100%'});
})
document.querySelector('iframe[name="content2"]').contentWindow.addEventListener('load',function(e){e.target.body.style.textAlign='center'},false)
This is a common problem but the answer is same that you can't access things in <iframe>
neither with css nor with jquery.
If you have access to the page you are using in <iframe>
go and write css on that page then it will be automatically work in <iframe>
. But you cant change anything in <iframe>
with external code.