I am new to HTML and learning it from w3schools. I am looking at object tag and trying to display a pdf in a browser. I am unable to understand why the height attribute doesn't work in below code
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 CSS 或任何地方,也为 html 和 body 设置高度,
html, body{ height: 100%; min-height: 100%; }
我认为问题在于您的内容很小,因此文档本身不会占用太多空间,因此 100% 的文档不会显示在整个页面中。
不设置 html 和 body 的最小高度和高度,
JSFIDDLE 1
在为 html、body 设置 min-height 和 height 之后,
JSFIDDLE 2
<script> $('object').attr({'width':$( window ).width()}) $('object').attr({'height':$( window ).height()}); </script>
<object data="index.html" type="text/html"><p>This is the fallback code!</p></object>