div.container {
display: flex;
flex-direction: column;
height: 100%;
}
div.container div.block {
display: flex;
justify-content: center;
align-items: center;
}
div.container div.advanced-items {
display: flex;
flex-direction: column;
overflow-y: scroll;
height: 100%;
}
div.container div.advanced-items span {
height: 100px;
}
<div class="container">
<div class="block">
<span>some data here</span>
</div>
<div class="block">
<span>some data here</span>
</div>
<div class="advanced-items">
<span>1. item</span>
<span>2. item</span>
<span>3. item</span>
<!-- more items here -->
</div>
</div>
div.advanced-items
的高度值设置为100%
,但在某种程度上等于整个div.container
的高度。但是考虑到孩子的身高,我需要填充div.container
的剩余高度。
请帮我,怎么做?
答案 0 :(得分:0)
考虑到孩子的身高,我需要填写div.container
的剩余高度。
究竟是怎么回事,只需将border
添加到div.advanced-items
即可看到它包裹了多少空间
div.container {
display: flex;
flex-direction: column;
height: 100%;
border: 1px solid black;
}
div.container div.block {
display: flex;
justify-content: center;
align-items: center;
}
div.container div.advanced-items {
display: flex;
flex-direction: column;
overflow-y: scroll;
height: 100%;
border: 1px solid black;
}
div.container div.advanced-items span {
height: 100px;
}
<div class="container">
<div class="block">
<span>some data here</span>
</div>
<div class="block">
<span>some data here</span>
</div>
<div class="advanced-items">
<span>1. item</span>
<span>2. item</span>
<span>3. item</span>
<!-- more items here -->
</div>
</div>
现在,您将div.advanced-items
包裹了除上面divs
包裹的包裹之外的所有左边的高度,但是您可以通过将height
设置为{ {1}}
100%
div.container {
display: flex;
flex-direction: column;
height: 100%;
border: 1px solid black;
}
div.container div.block {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
border: 1px solid black;
}
div.container div.advanced-items {
display: flex;
flex-direction: column;
overflow-y: scroll;
height: 100%;
border: 1px solid black;
}
div.container div.advanced-items span {
height: 100px;
}
答案 1 :(得分:0)
您要这样吗? :
<div class="container">
<div class="block">
<span>some data here</span>
</div>
<div class="block">
<span>some data here</span>
</div>
<div style="--item-count:3;" class="advanced-items">
<span>1. item</span>
<span>2. item</span>
<span>3. item</span>
<!-- more items here -->
</div>
</div>
div.container {
display: flex;
flex-direction: column;
height: 100%;
}
div.container div.block {
display: flex;
justify-content: center;
align-items: center;
}
div.container div.advanced-items {
display: flex;
flex-direction: column;
justify-content: stretch;
overflow-y: scroll;
height: 100%;
}
div.container div.advanced-items span {
height: 100px;
}
还是这个? :
<div class="container">
<div class="block">
<span>some data here</span>
</div>
<div class="block">
<span>some data here</span>
</div>
<div style = "--itemCount:3;" class="advanced-items">
<span>1. item</span>
<span>2. item</span>
<span >3. item</span>
<!-- more items here -->
</div>
</div>
private void button2_Click(object sender, EventArgs e)
{
if ( textBox1.Text == "" )
{
MessageBox.Show(...);
return;
}
answer = Convert.ToInt32(textBox1.Text);
...
}