Auto height in iframe?

0

I have an iframe and I need the height of it to be automatic according to the content inside it. How can I do this? No jquery of preference.

    
asked by anonymous 02.12.2016 / 21:02

3 answers

1

Unfortunately, you can not leave the iframe with automatic height according to content.

The only way to solve the problem is to implement a Javascript within the iframe that sends the height of the body (from within the iframe) out of the iframe via postMessage. Receiving height, you resize the iframe.

The link below has an explanation of how to do this:

link

    
03.12.2016 / 04:13
0

Create a class and assign the 'height: auto' property, if you wanted to limit a max size you can use max-height: ''.

Html

<iframe class="frame"></iframe>

Css

.frame{height:auto;max-heignt:100px;}
    
02.12.2016 / 21:33
0

You need to set in the body and html tag height value: 100%, following example:

body, html {
  height:100%;
}

iframe {
  height:100%;
  width:100%;
  background:cyan;
}
<iframe></iframe
    
02.12.2016 / 22:47