将Min-vh-100设置为Div的,已经在Min-VH-100的尸体中
我试图将Div的最小高度设置为容器的100%或100VH。
但是:
设置最小值:100%
div不起作用,
将类min-vh-100
添加到DIV的高度比父级要高。
<body class="min-vh-100 d-flex flex-column bg-primary">
<header class="p-3 bg-success">
Header<br/>
Content
</header>
<div class="container flex-grow-1 p-0 bg-secondary">
<div class="d-flex flex-column"><!-- What do I have to do here to set this DIV's height to 100% of parent DIV ? -->
<div class="flex-grow-1 p-3 bg-danger">
Main Content that's need to fill up vertical space
</div>
<div class="p-3 bg-warning">
Bottom Content for Main
</div>
</div>
</div>
<footer class="p-3 bg-info">
Footer<br/>
Content<br/>
© 2022 Bootstrap
</footer>
</body>
这就是我想要的:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Footer at Bottom when content is not page-full</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body class="min-vh-100 d-flex flex-column bg-primary">
<header class="p-3 bg-success">
Header<br/>
Content
</header>
<div class="container flex-grow-1 p-0 bg-secondary">
<div class="d-flex flex-column">
<div class="flex-grow-1 p-3 bg-danger">
Main Content
</div>
<div class="p-3 bg-warning">
Bottom Content for Main
</div>
</div>
</div>
<footer class="p-3 bg-info">
Footer<br/>
Content<br/>
© 2022 Bootstrap
</footer>
</body>
</html>
I am trying to set a DIV's min-height to 100% or 100vh of the container.
But:
setting min-height:100%
to the DIV isn't working and
adding class min-vh-100
to the DIV is giving it's height more than the parent DIV.
<body class="min-vh-100 d-flex flex-column bg-primary">
<header class="p-3 bg-success">
Header<br/>
Content
</header>
<div class="container flex-grow-1 p-0 bg-secondary">
<div class="d-flex flex-column"><!-- What do I have to do here to set this DIV's height to 100% of parent DIV ? -->
<div class="flex-grow-1 p-3 bg-danger">
Main Content that's need to fill up vertical space
</div>
<div class="p-3 bg-warning">
Bottom Content for Main
</div>
</div>
</div>
<footer class="p-3 bg-info">
Footer<br/>
Content<br/>
© 2022 Bootstrap
</footer>
</body>
This is what I want :
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Footer at Bottom when content is not page-full</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body class="min-vh-100 d-flex flex-column bg-primary">
<header class="p-3 bg-success">
Header<br/>
Content
</header>
<div class="container flex-grow-1 p-0 bg-secondary">
<div class="d-flex flex-column">
<div class="flex-grow-1 p-3 bg-danger">
Main Content
</div>
<div class="p-3 bg-warning">
Bottom Content for Main
</div>
</div>
</div>
<footer class="p-3 bg-info">
Footer<br/>
Content<br/>
© 2022 Bootstrap
</footer>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有JavaScript的使用,我似乎无法解决此问题。
I can't seem to solve this without the use of JavaScript.