html - 如何让HTML页面适合屏幕?

标签 html css

我正在设计一个使用 html 和 css 的网页,我制作了一个包含所有页面并由其他 div 组成的 div(像往常一样),但是当运行该页面时,它的高度大约是浏览器高度的 150% :

enter image description here

和包含所有页面的 div:

#items {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
    left: 0px;
    top: 0px;
}

和 html 代码:

<div id="items">
<select id="heap" class="basic-example"></select>
<img src="img/bg.png" class="responsive-image">

<div id="dummy"></div>

<div id="gallery">

</div>

  <span id="order_list">
  <img src="img/ItemList.png" class="responsive-image">
<div id="confirm" class="buttonClass">
  <div align="center">Confirm</div>
</div>    

<div id="total" class="totalClass">
  <div align="center"></div>
</div>  
  </span>

</div>

最佳答案

这是你的问题:

您的内部容器位置低于 0,但高度为 100%。你看到的溢出部分是从你的位置 top:35px 开始的 35px。

#items {
    position: absolute;
    width: 100%;
    /*height: 100%;*/ /* removed */
    bottom:0; /* added */
    z-index: 1;
    left: 0px;
    top: 0px;
}
#gallery {
    position: absolute;
    width: 75%;
    /*height: 100%;*/ /* removed */
    bottom:0; /* added */
    z-index: 1;
    top: 35px;
}
#order_list {
    position: absolute;
    width: 25%;
    /*height: 100%;*/ /* removed */
    bottom:0; /* added */
    z-index: 2;
    left: 75%;
    top: 35px;
    color: #F33;
    background:url(img/ItemList.png) display: inline-block;
    alignment-adjust: central;
    font: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-size-adjust: inherit;
    grid-rows: inherit;
    list-style: upper-alpha;
    word-spacing: inherit;
    word-wrap: break-word;
    vertical-align: central;
}

You jsfiddle with height:100%; removed and bottom:0; added

关于html - 如何让HTML页面适合屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20724141/

相关文章:

javascript - 使用 jquery 显示从 xml 到 html 的新行

java - 在字符串变量中可以存储所有 ASCII 符号是否正确?

javascript - 如何用jq一键换图

javascript - 多个滑动div的时间和速度

html - 在angular2中迭代数组

javascript - 如何获取由 chrome.windows.create() 创建的弹出窗口的窗口 ID

javascript - 从动态呈现的模板中获取特定 id 的 HTML

html - 表单未按预期显示

javascript - jquery datepicker 多个 css 类

html - 媒体查询不适用于 Iphone(Safari 和 Chrome)