html - 如何将最小高度设置为屏幕的 100% 和页面的一半?

标签 html css twitter-bootstrap height

我有一个单页网站,其中第一部分主要部分应该是观众屏幕/浏览器大小的 100%,第二部分应该在查看区域下方,所以当用户点击链接时,页面会向下滚动到第二部分。

我如何实现这一点。, 到目前为止我已经试过了,但它没有设置最小高度 yo 100%

HTML:

<div class="container">
<div class="firsthalf">
this is the first part of the site
<a href="#help"> <i class="fa fa-question-circle fa-lg"></i>
<div class="notice">this is aligned to bottom of first half
</div></div>   
</div>    

<div class="container">
<div id="help" class="secondhalf">
<div class="col-md-8 col-md-offset-2">
<div class="well">
we are in second part of the site
</div>
<a href="#top" class="btn btn-default"><i class="fa fa-arrow-up "></i> Top</a>
</div>
</div>
</div>

CSS:

body, html {
  height: 100%;
}
.firsthalf{
height:100%;
}
.notice{
margin-bottom:0%;
padding-bottom:5px;
}
.secondhalf{
margin-top:25%;
margin-bottom:50%;
padding-top:25px;
min-height:50%;

}

http://jsfiddle.net/4yk2q/

最佳答案

position: relative;position: absolute;...在这种情况下他们是你的 friend ...

Solution demo

body, html {
    height: 100%;
}
.container {
    height:100%;   /* first make container full height */
}
.firsthalf {
    height:100%;
    border:1px solid #000;
    position: relative; /* make parent div relative */
}
.notice {
   padding-bottom:5px;
   position: absolute; /* this does the base line trick */
   bottom: 0;
   right: 0;
}

关于html - 如何将最小高度设置为屏幕的 100% 和页面的一半?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20968804/

相关文章:

jquery - 无法在单击时选择可编辑的 jQuery 中的完整文本

javascript - 将可编辑字段中的文本复制到不可编辑的段落中,无需刷新

php - 在模态中显示查询中的数据

javascript - 获取 innerHtml 但删除不需要的标签

html - Literally Canvas - 我在我的页面上找不到任何工具?

javascript - 使用html注释实现lazyload

html - CSS 表格行背景色与表格背景色

html - 如何移动图片下方的内容?

html - 旋转木马 Bootstrap 倒置

javascript - 模态 mask 出现在模态元素上