简体   繁体   English

HTML Fullscreen API,如何使其对动态生成的div响应(高度钳制)

[英]HTML Fullscreen API , how to make it responsive (height vise) for dynamically generated divs

I am creating multiple dynamic divs of fixed height inside a main div. 我正在主div内创建多个固定高度的动态div。 I can't change the fixed height to % height because it has to have a fixed height even if its empty because user drags elements onto these divs afterwards. 我无法将固定高度更改为%height,因为即使它为空,它也必须具有固定高度,因为用户随后将元素拖到这些div上。 Now i am using the Full Screen API to enlarge the main div to full screen. 现在,我正在使用全屏API将主div放大到全屏。 and i want the inside divs to grow their height as the screen enlarges. 而且我希望随着屏幕的扩大,内部div的高度会增加。

On Small Screen it looks like this 在小屏幕上看起来像这样 在此处输入图片说明

On Full Screen it looks like this 在全屏上看起来像这样 在此处输入图片说明

on full screen the inside divs adjusted their widths accordingly because they have taken widths % vise but the height of divs doesn't increase because its fixed pixels. 在全屏模式下,内部div会相应地调整其宽度,因为它们的宽度为%vise,但是div的高度不会增加,因为其像素固定。 The red area in the second image shows the empty space when in full screen mode. 在第二张图像中的红色区域处于全屏模式时显示空白区域。 how could this area be taken by the divs divs如何占用这个区域

The actual code of this is too much complex and lengthy so i am writing here a sample code to understand the problem 实际的代码太复杂和冗长,因此我在这里编写示例代码来理解问题

<div id="main"> 
  <div Class="Row">
     <div Class="Col-md-6">
        <div id="A" style="height:100px;width:50%">
        </div> 
     </div>
     <div Class="Col-md-6">
        <div id="B" style="height:100px;width:50%">
        </div>
    </div>
 </div>
 <div Class="Row">
     <div Class="Col-md-6">
        <div id="C" style="height:100px;width:50%">
        </div> 
     </div>
     <div Class="Col-md-6">
        <div id="D" style="height:100px;width:50%">
        </div>
    </div>
 </div> 

Like i said that divs A,B,C and D are created dynamically. 就像我说的那样,div A,B,C和D是动态创建的。 Now i apply a full screen function on main div 现在我在主div上应用全屏功能

 var element = document.getElementById("main");
 element.webkitRequestFullscreen();

The main div gets to Full screen but the divs A,B,C and D do not adjust their height accordingly. 主div进入全屏显示,但是div A,B,C和D不会相应地调整其高度。

write a media query like this-> 写这样的媒体查询->

@media screen and(min-width:fullscreenswidth) {
    .yourdiv {
              height:100vh;
       }
}

The fullScreenWidth is the size of the screen in pixels fullScreenWidth是屏幕尺寸,以像素为单位

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

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