简体   繁体   English

HTML5对象适合窗口高度

[英]HTML5 object fit window height

Using AdminLTE. 使用AdminLTE。

<object id="topo" data="http://www.web-source.net" type="text/html" width="100%" height="100%" style="min-height: 100%;"><p>This is the fallback code!</p></object>

The above code stretches the object width but not the height, the height is as small as possible. 上面的代码拉伸对象的宽度,但不拉伸高度,高度尽可能小。

How can I make it the same height as the window? 如何使它与窗户的高度相同?

使用CSS属性height: calc(100vh-100px)其中100px是您的标题高度,例如

create a container with the following CSS Viewport Units: vw, vh, vmin and vmax then you can use percentage to control DOM elements with display:block property: 创建一个容器具有以下CSS视域单位:大众,VH,Vmin和Vmax ,那么你可以用百分比来控制与DOM元素display:block属性:

.container {
  height: 90vh;
  background-color: #ccc;
}

object {
  border: 1px solid red;
  display: block;
  height: 80%;
}

object > p {
  background-color: #fff;
  height: 50%;
  padding: 10px;
  margin:0;
}
<div class="container">
  <object id="topo" data="http://www.web-source.net" type="text/html" width="100%" height="100%" style="min-height: 100%;">
    <p>This is the fallback code!</p>
  </object>
</div>

https://jsfiddle.net/eapo/ba2cnc9r/ https://jsfiddle.net/eapo/ba2cnc9r/

如果我正确理解您的问题,则问题出在默认的正文边距上,请将正文的边距设置为0:

body{margin: 0px;}

您可以设置:

body{min-height: 100vh;}

Just use the style below: 只需使用以下样式:

html, body {
   height: 100%;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM