gpt4 book ai didi

html - CSS Flexbox 文本超出 div

转载 作者:行者123 更新时间:2023-11-28 03:19:30 25 4
gpt4 key购买 nike

我希望元素 nav#left#right 始终具有相同的高度,并且其中的文本始终位于元素而不是外部。

<body>
<header>
text
</header>
<main>
<nav>
some links
</nav>
<section id="content">
<div id="headline">
Text
</div>
<div id="contentText">
<div id="left">
text
</div>
<div id="right">
text
</div>
</div>
</section>
</main>
</body>

我的 CSS:

 header { 
display: flex;
height: 60px;
width: 100%;
background-color: green;
}
#logo{
width: 15%;
background-color: red;
}
#messages{
width: 5%;
background-color: yellow;
}
#notifications{
width: 5%;
background-color: red;
}
#search{
width: 5%;
background-color: yellow;
}
#searchArea{
flex: 1;
background: red;
}
#profileArea{
width: 10%;
background: yellow;
}
#options{
width: 3%;
background: red;
}
main{
display: flex;
width: 100%;
height: calc(100% - 60px);
min-height: calc(100% - 60px);
background: blue;
}
nav {
width: 15%;
min-height: 100%;
background-color: green;
}
.link{
width: 100%;
height: 3%;
background-color: yellow;
}
#content{
display: flex;
flex-direction: column;
width: 85%;
height: 100%;
min-height: 100%;
background: grey;
}
#headline{
width: 100%;
height: 5%;
background-color: pink;
}
#contentText{
display: flex;
width: 100%;
height: 95%;
background: red;
}
#left{
width: 50%;
height: 100%;
background: red;
}
#right{
width: 50%;
height: 100%;
background: yellow;
}

有关更多信息,请查看我的 JsFiddle

最佳答案

删除#contentText 应有的高度

#contentText{
display: flex;
width: 100%;

background: red;
}
main{
display: flex;
background: blue;
}
nav {
width: 15%;
background-color: green;
overflow:auto;
}

关于html - CSS Flexbox 文本超出 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25303914/

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