当侧divs消失时,最佳方法可以使中间div大小?
每当我应用显示:无;到任何侧面。
当前,它适用于左右DIVS,但底部不起作用。当我添加显示:底部的画布上没有任何内容都不会调整到页面的其余部分。
关于如何使底部也起作用的任何想法?
html, body {
margin: 0;
padding: 0;
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
.ribbon {
background: beige;
height: 10vh;
}
.outer-col {
display: flex;
flex-direction: column;
}
.inner-col {
display: flex;
flex-direction: row;
flex: 1 1 0;
}
.inner-row {
flex: 6;
}
.canvas {
background: skyblue;
min-height: 70vh;
}
.left {
/* display: none; */
background: beige;
flex: 1;
}
.right {
/* display: none; */
background: beige;
flex: 1;
}
.bottom {
/* display: none; */
background: beige;
height: 20vh;
}
.ribbon, .bottom, .canvas, .ribbon, .left, .right {
border-style: solid;
}
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js"></script>
<script src="./script.js"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="ribbon"></div>
<div class="outer-col">
<div class="inner-col">
<div class="left"></div>
<div class="inner-row">
<div class="canvas"></div>
<div class="bottom"></div>
</div>
<div class="right"></div>
</div>
</div>
</body>
</html>
I'm trying to use flexbox to resize my middle div ("canvas") whenever I apply display: none; to any of the side divs.
Currently, it works for both the right and left divs but the bottom one doesn't work. When I add display:none to the bottom canvas doesn't resize to the rest of page.
Any ideas on how to make the bottom one work as well?
html, body {
margin: 0;
padding: 0;
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
.ribbon {
background: beige;
height: 10vh;
}
.outer-col {
display: flex;
flex-direction: column;
}
.inner-col {
display: flex;
flex-direction: row;
flex: 1 1 0;
}
.inner-row {
flex: 6;
}
.canvas {
background: skyblue;
min-height: 70vh;
}
.left {
/* display: none; */
background: beige;
flex: 1;
}
.right {
/* display: none; */
background: beige;
flex: 1;
}
.bottom {
/* display: none; */
background: beige;
height: 20vh;
}
.ribbon, .bottom, .canvas, .ribbon, .left, .right {
border-style: solid;
}
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js"></script>
<script src="./script.js"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="ribbon"></div>
<div class="outer-col">
<div class="inner-col">
<div class="left"></div>
<div class="inner-row">
<div class="canvas"></div>
<div class="bottom"></div>
</div>
<div class="right"></div>
</div>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那是因为没有足够的内容来填充整个屏幕视口高调。
您可以应用
最小值:100VH
在html
和/或body
上,然后应用高度:100%
在两个上。
vh
- 单位代表视口高,其价值为百分比(以其独特的方式)。100VH
是视口屏幕的100%,50VH
为50%,依此类推。That's because there's not enough content to fill up the entire screens viewport-height.
You can apply
min-height: 100vh
onhtml
and/orbody
, and then applyheight: 100%
on both.outer-col
and.inner-col
to let them take the remaining space that is set with100vh
.The
vh
-unit stands for viewport height and its value is in percentages (in its own unique way).100vh
is 100% of the viewport screen,50vh
is 50% and so on.