html - 响应式 DIV 填满整个屏幕

标签 html css responsive-design

我正在尝试格式化 HTML DIV 元素,以便它在移动设备上响应。我的目标是让潜水始终填充任何移动设备的宽度和高度的 100%,无论是 ipad、iphone 还是 android 设备。 IE。不同尺寸的屏幕。

但是,我无法让此代码执行此操作。我哪里出错了?

我的 DIV 元素:

<!---Main Responsive DIV --->
    <div class="fullscreen" id="fullscreen">

    <!--- This is where we draw. --->
    <div align="center" style="vertical-align:middle">
    <canvas
    id="canvas"
    width="400"
    height="250"
    style="border:3px dashed #000000;">
    </canvas>
    </div>

      <!---
    This is the form that will post the drawing information
    back to the server.
    --->
      <cfoutput>
        <form action="signature_action.cfm?ticketID=#url.ticketID#&TT=#url.TT#&techID=#url.techID#&device=ipad" method="post">

          <!--- The canvas dimensions. --->
          <input type="hidden" name="width" value="1000" />
          <input type="hidden" name="height" value="615" />

          <!--- The drawing commands. --->
          <input type="hidden" name="commands" value="" />
          <!--- This is the export feature. --->

          <!--- Navigation Elements --->
          <div id="footer">
          <A HREF="javascript:history.back()">Go back</A><a href="">Capture Signature</a>
          </div>

        </form>
      </cfoutput>
      </div>

我的 CSS:

#fullscreen {
        height: 100vh;
        width: 100vw;
        position:fixed;
        top:0;
        left:0;
        background: pink;
        @

    }
    @media screen and (orientation:portrait) { height: 100vh;
        width: 100vw; }

    @media screen and (orientation:landscape) {height: 100vh;
        width: 100vw; }

    #footer {
       position:absolute;
       bottom:0;
       width:100%;
       height:110px;   /* Height of the footer */
       background:#6cf;
    }

    table
    {
       border-collapse:collapse;

    }
    table.borderAll
    {
       border-bottom: 2px solid #000;
    }
    tr.bottomMedium
    {
       border-bottom: 2px solid #000;
    }
    tr.bottomThin
    {
       border-bottom: 2px solid #000;
    }
    tr.bottomDouble
    {
       border-bottom: 2px double #000;
    }
    tr.last
    {
       border-bottom: none;
    }

    </style>

最佳答案

您可以使用 CSS3 的 vwvh 调整大小 units

   #fullscreen {
        height: 100vh;
        width: 100vw;
        position:fixed;
        top:0;
        left:0;
    }

定义:

100vw = 100% of viewport width
100vh = 100% of viewport height
1vmin = 1vw or 1vh, whichever is smaller
1vmax = 1vw or 1vh, whichever is larger

更新:

 @media screen and (orientation:portrait) { height: 100vh;
            width: 100vw; }
 @media screen and (orientation:landscape) {height: 100vh;
            width: 100vw; }

关于html - 响应式 DIV 填满整个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26040678/

相关文章:

html - 使用 flexbox 在元素之间留空间的问题

html - CSS:新 CSS 网格的全宽背景

html - 仅 CSS Accordion 布局

javascript - Bootstrap 显示点击结果而不刷新页面

html - CSS 列数下降被截断,流入下一列

jquery - 响应式设计,网站在手机上不滚动

html - 如何在悬停时实现此 "underline"效果,耗尽选项

html - Bootstrap 卡片中的中心进度条

html - 防止行流体跨度在小屏幕尺寸下堆叠 - twitter bootstrap 2.3.2

html - 用于响应式布局的标记和 CSS, float div 与顶部对齐