jquery - 用流体容器填充整个高度

标签 jquery html css

这应该是一个简单的修复,但我似乎无法弄清楚。我试图将我的容器流体类一直延伸到窗口底部,但它不起作用。我已经尝试应用

中的所有内容

Height not 100% on Container Fluid even though html and body are

但没有一个有效。这是我的 html 和 css:

html:

<div class="container-fluid fill-height">
  <h1 class="text-center">WikiGen</h1>

  <div class="row fill-height">
    <div class="col-md-3">
    </div>
    <div class="col-md-3">
      <label class="align-top">Search for an article:</label>
    </div>
  </div>

  <div class="row fill-height">
    <div class="col-md-3">
    </div>
    <div class="col-md-3">
      <label class="align-top">Or, pick one at random:</label>
    </div>
    <div class="col-md-3">
      <a href="https://en.wikipedia.org/wiki/Special:Random">
        <img id = "dice" src="https://lh3.ggpht.com/kOal-qldAR-YwTvStekh0NbGnwUz-kB5idDv97ZOODRZnxKCs-52YNHLkZX3Ttbjv890=w300"/>
      </a>
    </div>
    <div class="col-md-3">
    </div>
  </div>
</div>

CSS:

.fill-height {
    min-height: 100%;
    height:auto !important; 
    height: 100%; 
}
.container-fluid {
  background: grey;
}
h1 {
  font-family: "Indie Flower";
  font-size: 100px;
}
h3 {
  margin: 10px;
  font-size: 20px;
}
label{
    display: inline-block;
    float: right;
    clear: left;
    width: 250px;
    font-size: 18px;
    margin: 5.5px;
    text-align: right;
}
input {
  margin: 5px;
  width: 300px;
  float: left;
}
.col-md-3 {
/*   background: black; */
}
#dice {
  width: 50px;
  height: 50px;
  margin-top: -5px;
  margin-left: 40px;
  mix-blend-mode: multiply;
}
.row {
  margin-bottom: 50px;
}
#button {
  margin-top: 2px;
}

最佳答案

你可以在这里利用 View 高度

.fill-height{
   height: 100vh;
}

您可以将父元素(可能是容器流体)的高度设置为 100vh,并相应地设置子元素的高度 请看一下 viewport-sized-typography .

关于jquery - 用流体容器填充整个高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41986728/

相关文章:

javascript - 为元素状态预加载图像

javascript - 如何在 JavaScript 中通过这个谜题?

javascript - 获取 <DIV> 的高度 - 返回 'undefined'

css - 为什么 Font-Size 和 CssClass 属性在 aspx 页面的 CheckBoxList 中不起作用?

javascript - JQuery 单击事件不能与 <i> 元素一起正常工作

javascript - 为什么我无法选择jquery中的元素并更改内容

php - 双击编辑 Kendo Grid incell 或内联编辑

jquery - 重复页面的背景图像全长

javascript - 将 HTML 列表项更改为在导航栏中处于事件状态

html - CSS - 无法在 Internet Explorer 中正确应用 z-index