简体   繁体   English

动态高度 <div> 引导程序3

[英]Dynamic Height for <div> Bootstrap 3

I have a <div> like this: 我有一个<div>像这样:

<div class="embed-responsive embed-responsive-16by9">
       <iframe class="embed-responsive-item" src="slider.html"></iframe>
</div>

But when I decrease the screen size to small or medium, I will get white-space beneath the <div> . 但是,当我将屏幕尺寸减小到中小尺寸时,我将在<div>下获得空白。

Like This: 像这样:

在此处输入图片说明

How can I have a dynamic height for this <div> to avoid the white-space? 如何为此<div>设置动态高度以避免空白?

You need using javascript to discover the dynamic height. 您需要使用JavaScript来发现动态高度。

We have some functions in this links: make iframe height dynamic based on content inside- JQUERY/Javascript 我们在此链接中提供了一些功能: 根据内部内容(JQUERY / Javascript)使iframe高度动态

and call when the browser resize. 并在浏览器调整大小时调用。

use media query like and add it to custom css 使用喜欢的媒体查询并将其添加到自定义CSS

this is just a sample 这只是一个样本

@media (min-width: 992px) and (max-width: 1199px) {
 .visible-md-block {
 display: block !important;
}

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

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