html - The height of the body in the iframe is the same as the iframe -


i have question height of body in iframe .

body block-level element,so if don't set height , nothing in body,the height of body 0;

enter image description here

now, find that, when body in iframe, it's height same iframe.(if iframe has it's own height)

for example: html file , iframe empty, it's height 500px.

body in iframe empty too, it's height 500px too.

why body empty it's height same iframe?

i see quirks mode in blogs,but appear in html5 <!doctype html>?

<!doctype html> <html lang="en"> <head>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <meta http-equiv="x-ua-compatible" content="ie=edge">     <title>document</title>     <style>         *{             margin:0;             padding:0;         }         iframe{             width:500px;             height:500px;         }     </style> </head>  <body>     <iframe src="" frameborder="0"></iframe> </body> <script> </script> </html>  

enter image description here

i has same problem before, can answer question. body inside iframe took same height because inheriting parent height means iframe height whatever defined. example,

<iframe width="100%" height="300px"></iframe> 

so height of body inside of iframe "300px".


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -