代码之家  ›  专栏  ›  技术社区  ›  Vishnudev Krishnadas

移动与桌面中的引导4列高度

  •  -1
  • Vishnudev Krishnadas  · 技术社区  · 6 年前

    我有两列大小的桌面 6 每一个。

    enter image description here

    在移动设备中,我需要这些列来适应手机的高度,也就是说。

    enter image description here

    如何根据设备使用Bootstrap 4实现可变高度?

    我用的是,

    <div class="row h-100">
        <div class="col-xl-6 h-100"></div>
        <div class="col-xl-6 h-100"></div>
    </div>
    

    怎么得到那个 h-100 根据设备的不同而变化,例如 h-sm-50 h-xl-100 是吗?

    2 回复  |  直到 6 年前
        1
  •  1
  •   Ahmed El-sayed    6 年前

    没有高度等级随设备而变化

    唯一可用的是根据视窗的不同而变化 bootstrap Sizing

    因此,您可以使用自定义类仅在使用 css media queries

    例子

    HTML格式

    <div class="row h-100">
        <div class="col-xl-6 mobile-100"></div>
        <div class="col-xl-6 mobile-100"></div>
    </div>
    

    自定义CSS

    @media only screen and (max-width: 600px) {
      .mobile-100 {height:100vh}
    }
    
        2
  •  1
  •   Carol Skelly    6 年前

    使用Bootstrap的 flex-grow-1 上课。这样在桌面或移动设备上宽度和高度相等。

    <div class="row min-vh-100">
          <div class="col-xl-6 d-flex flex-grow-1">
          </div>
          <div class="col-xl-6 d-flex flex-grow-1">
          </div>
    </div>
    

    https://www.codeply.com/p/05LpUi7VUa

    编辑: 使整个布局 最大100%高度 ,可以使用绑定到引导的媒体查询 xl 1200像素的断点。

    @media (max-width: 1200px) {
        .flex-fill-50 {
            height:50vh
        }
    }