简体   繁体   English

删除iframe下的空白

[英]Removing white space below iframe

I am currently trying to remove white space below my iframe when resizing. 我目前正在尝试在调整大小时删除iframe下方的空白区域。 I am mainly using Bootstrap for CSS. 我主要使用CSS的Bootstrap。 The goal is to have the iframe take 100% of the page below the navbar. 目标是让iframe占据导航栏下方100%的页面。

Example of iframe being cut off and white space trailing iframe被切断和空格拖尾的示例

This is how I am calling the iframe: 这就是我所说的iframe:

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="site/index.html">
    <p>Your browser does not support iframes.</p>
  </iframe>
</div>

The only other element in the page is the navbar. 页面中唯一的其他元素是导航栏。

I have tried the following: Changing the iframe to display:block height and width:100% overflow:hidden overflow-y:hidden 我尝试了以下操作:将iframe更改为显示:块高度和宽度:100%溢出:隐藏溢出-y:隐藏

Thank you. 谢谢。

  • Use h-100 class for the html tag. h-100类用于html标签。
  • Use d-flex flex-column h-100 for the body. 对身体使用d-flex flex-column h-100
  • Use flex-grow-1 for the embed-responsive so that it takes the rest of the available space. embed-responsive使用flex-grow-1 ,以便占用剩余的可用空间。

 <!DOCTYPE html> <html class="h-100"> <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css"> </head> <body class="d-flex flex-column h-100"> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <h1 class="mx-auto">iframe</h1> </nav> <div class="flex-grow-1 embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src="https://getbootstrap.com/"> </iframe> </div> </body> </html> 


You need to use bootstrap-4.1 您需要使用bootstrap-4.1

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

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