子项隐藏在父项之外,具有display:inline blox和overflow:auto



我遇到了一些问题,最后一个子页/最后一个子页边空白隐藏在页面的父页之外/而父页具有最大高度:-webkit fill可用;高度:自动;显示:内联块;和溢出:auto,如https://jsfiddle.net/andreasjj/ok9hqgxv/2/

<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
body, html {
font-size: 16px;
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
height: 100vh;
display: flex;
flex-direction: column;
}
#root {
height: inherit;
min-height: inherit;
overflow: hidden;
}
#wrapper {
display: flex;
flex-direction: column;
height: inherit;
min-height: inherit;
width: inherit;
}
#header {
display: flex;
flex-direction: row;
align-items: center;
min-height: 50px;
width: inherit;
background-color: #f8f8f8;
}
#container {
display: flex;
flex-direction: row;
width: inherit;
height: inherit;
}
#content {
height: inherit;
width: 100%;
overflow: hidden;
}
#box {
display: flex;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: center;
justify-content: center;
height: inherit;
width: inherit;
}
#box-content {
max-height: -webkit-fill-available;
height: auto;
overflow: auto;
display: inline-block;
padding: 0.75rem;
width: calc(100vw - 1.0rem);
max-width: 900px;
}
.module {
background-color: black;
border: 1px solid #e9e9e9;
padding: 1.0rem;
margin-bottom: 3rem;
width: 541px;
height: 461px;
}
.module:first-child {
margin-top: 3rem;
}
</style>
</head>
<body>
<div id="root">
<div id="wrapper">
<div id="header"></div>
<div id="container">
<section id="content">
<div id="box">
<div id="box-content">
<div class="module"></div>
<div class="module"></div>
</div>
</div>
</section>
</div>
</div>
</div>
</body>
</html>

最后一个黑框缺少大部分隐藏的边距(如果删除边距,框本身的一部分将被隐藏(。

我试着改变不同祖先的高度,最大高度,以及不同的显示值。但似乎什么都不起作用。有什么想法吗?

html的结构可能看起来有点奇怪,但这是从react应用程序中提取的html和css,所以我想保持结构的相似性,以免破坏整个东西

我不确定我是否完全理解您的问题,但我总是用以下代码来启动CSS脚本:

* {
margin: 0;
padding: 0;
box-sizing: border-box;
} 

*的意思是"选择所有内容",框大小可以确保所有额外的边距和边框都包含在对象的大小中
https://www.w3schools.com/css/css3_box-sizing.asp

希望它对你有用

最新更新