[英]Setting 100% on a child of body overflows the page
這是 css
body, html {
height: 100%;
width: 100%;
}
#container {
display: flex;
position: absolute;
flex-flow: column wrap;
justify-content: stretch;
align-items: center;
width: 100%;
height: 100%;
text-align: center;
background-color: black;
}
div.sections {
display: flex;
flex-flow: row wrap;
justify-content: left;
align-items: stretch;
margin: 0;
padding: 0;
width: 100%;
color: black;
background-image: linear-gradient(0, orange, gold);
border-top: 2px solid black;
border-bottom: 2px solid black;
}
其中#container
是div.sections
的兄弟,都直接在 body 標簽下。 問題是#container
的高度超出了div.sections
的高度。 我不知道這里有什么問題,或者它是否與 flex 有關。 我確實知道如何用 javascript 解決它,但我真的很想在 css 中看到解決方案。
我試圖為您的父div.sections
設置一個特定的高度值,例如height: 500px;
這將解決您的問題。 謝謝
div.sections {
display: flex;
flex-flow: row wrap;
justify-content: left;
align-items: stretch;
margin: 0;
padding: 0;
height: 500px; /* Height Value as you want */
width: 100%;
color: black;
background-image: linear-gradient(0, orange, gold);
border-top: 2px solid black;
border-bottom: 2px solid black;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.