bootstrap可滚动div到身高100%

时间:2016-09-24 02:15:08

标签: css css3 twitter-bootstrap-3

我想让身体固定在100%高度,身体内的主要div可滚动并且有一些边缘。像这样:

enter image description here

2 个答案:

答案 0 :(得分:2)

你真的不需要Bootstrap!

如果您无法运行代码段,则这是CodePen上的笔:http://codepen.io/kranzy/pen/bwqWbo

body {
  margin: 0;
}
.full {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: red;
  overflow: hidden;
}
.inside {
  position: relative;
  /* some bit of margins */
  top: 50px;
  left: 50px;
  /* calculate the width, if not, weird effect. */
  width: calc(100% - 50px * 2);
  height: calc(100% - 50px * 2);
  /* 50px * 2 because 50px is just enough for the .inside div's width and height not to fall out of screen. */
  /* make it like your image */
  background-color: blue;
  overflow: auto;
}
<div class="full">
  <div class="inside"></div>
</div>

答案 1 :(得分:0)

<div class="main" style="background-color:red; height:100vh; float:left; width:100%;>

    <div class="wrapper" style="width:1170px;margin:0 auto">
    <div class="main-text" style="float:left; width:100%; background-color:blue;">

</div>

<div>

</div>