如何使HTML页面适合屏幕?

时间:2013-12-21 22:20:42

标签: html css

我正在使用带有CSS的html设计一个网页,我创建了一个包含所有页面的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>

1 个答案:

答案 0 :(得分:2)

这是你的问题:

内部容器的位置低于0但高度为100%。您所看到的过度热量是从您的位置顶部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