gpt4 book ai didi

html - 当 parent 没有更多的成长空间时如何使 child 滚动

转载 作者:可可西里 更新时间:2023-11-01 13:46:42 25 4
gpt4 key购买 nike

enter image description here

这是我的尝试: http://jsbin.com/xokidev/7/edit?html,output

  <phone style="
display:block;
position:relative;
margin:auto;
width:300px;
height:500px;
background:silver;
overflow:hidden">
<navigation-or-something style="
display:block;
position:absolute;
height:100px;
width:100%;
background:skyblue">
known height. don't overlap
</navigation-or-something>
<component style="
position: absolute;
right:0;
bottom:0;
left:0;
max-height: calc(100% - 100px);
display:block;">
<header style="background:yellow">
multiline variable text height. multiline variable text height
</header>
<container style="
display:block;
background: pink;
overflow-y:auto;">
<content>
some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content.
</content>
</container>
</component>
</phone>

您会发现的问题是,一旦父级没有更多的增长空间,我的粉红色子级就不会开始滚动。

最佳答案

使用 display: flex;flex-direction: column; 让它只滚动粉色部分

<phone style="
display:block;
position:relative;
margin:auto;
width:300px;
height:500px;
background:silver;
overflow:hidden">
<navigation-or-something style="
display:block;
position:absolute;
height:100px;
width:100%;
background:skyblue">
known height. don't overlap
</navigation-or-something>
<component style="
position: absolute;
right:0;
bottom:0;
left:0;
max-height: calc(100% - 100px);
display: flex;
flex-direction: column;">
<header style="background:yellow">
multiline variable text height. multiline variable text height
</header>
<container style="
display:block;
background: pink;
overflow-y:auto;">
<content>
some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable
height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height
content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content.
some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some
variable height content. some variable height content. some variable height content. some variable height content. some variable height content. some variable height content.
</content>
</container>
</component>
</phone>

关于html - 当 parent 没有更多的成长空间时如何使 child 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41348999/

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