gpt4 book ai didi

css - Bootstrap 4 - 全高抽屉

转载 作者:太空宇宙 更新时间:2023-11-03 20:27:07 25 4
gpt4 key购买 nike

我正在开发一个使用 Bootstrap 4 的应用程序。此外,我正在使用 material design framework .我需要这个应用程序占据整个屏幕并使用作为框架一部分的抽屉。我可以通过使用 flexbox 成功地让应用程序占据整个屏幕。但是,我似乎无法让抽屉占据所有可用高度。您可以在 this Fiddle 中查看问题. Fiddle 中的代码如下所示:

<div id="app" class="d-flex flex-column h-100">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>

<div class="d-flex flex-column flex-grow">
<div class="h-100 flex-grow">
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>

<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>

<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>

</div>
</main>
</div>
</div>


<footer>
<p>Thank you for visiting!</p>
</footer>
</div>

如何让抽屉占满 navfooter 区域之间的整个高度?

谢谢

最佳答案

一种方法是使包裹 .bmd-layout-container 的元素成为具有 flex-direction: column 的 flex parent,然后设置生成的 .bmd-layout-canvas 类到 flex-grow: 1

$(document).ready(function () { $('body').bootstrapMaterialDesign(); });
body, html {
height: 100%;
}

.flex-grow {
flex: 1 0 auto;
}

.bmd-layout-canvas {
flex-grow: 1;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/bootstrap-material-design@4.1.1/dist/css/bootstrap-material-design.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/bootstrap-material-design@4.1.1/dist/js/bootstrap-material-design.js"></script>
<div id="app" class="d-flex flex-column h-100">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>

<div class="d-flex flex-column flex-grow">
<div class="h-100 flex-grow d-flex flex-column">
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>

<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>

<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>

</div>
</main>
</div>
</div>


<footer>
<p>Thank you for visiting!</p>
</footer>
</div>

这是一个 fiddle - https://jsfiddle.net/n9c4Lbqa/

关于css - Bootstrap 4 - 全高抽屉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51408171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com