【发布时间】:2022-02-06 05:51:24
【问题描述】:
演示:https://jsfiddle.net/chovy/7vgLpm9h/7/
我很难让导航与内容一样高(或者如果您删除内容与导航一样高的内容)。
两者都应该是最高柱高度的 100%。
我还需要将最后一个导航项放在导航栏的底部。
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body,
main {
height: 100%;
min-height: 100vh;
width: 100vw;
}
main {
display: flex;
justify-content: flex-start;
align-items: flex-start;
}
aside {
width: 100rem;
border: 1px solid red;
align-self: stretch;
flex-grow: 1;
}
section {
flex-grow: 1;
border: 1px solid green;
}
nav li {
margin-bottom: 1rem;
}
nav li:last-child {
margin-top: auto;
margin-bottom: 0;
color: blue;
font-weight: 700;
}
<main>
<aside>
<header>header</header>
<nav>
<ul>
<li>link 1</li>
<li>link 1</li>
<li>link 1</li>
<li>link 1</li>
<li>link 1</li>
<li>link 1</li>
<li>link 1</li>
<li>link 1</li>
</ul>
</nav>
</aside>
<section>
grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column.
grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column.
grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column.
grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column.
grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column.
grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column. grow this to 100% of either column.
grow this to 100% of either column.
</section>
</main>
【问题讨论】:
-
删除:对齐项目:弹性开始; ?和所有的高度:100%?
-
似乎什么也没做。实际上更糟 - 如果你有解决方案,请分叉小提琴。
-
这行得通,但是如何让最后一个导航项位于框的底部?