我有一个XY网格,其中有一个偏移画布,但位于XY网格的主体中。我希望将偏移的画布位置保留为可用空间的全部高度,但它没有这样做。它根据画布内容的高度包装画布的高度。因此,画布高度仅根据画布的内容高度而增加。当我将离画布包装纸的高度设置为100%时,滚动会混乱。 我已经在此附加了Codepen的链接,以检查问题。
<div class="grid-y grid-frame">
<div class="cell shrink header">
<button type="button" class="button" data-toggle="offCanvasLeft">Open Menu</button>
<h1>Grid Frame Header</h1>
</div>
<div class="cell auto body">
<div class="off-canvas-wrapper">
<div class="off-canvas position-left off-canvas-absolute reveal-for-medium" id="offCanvasLeft" data-off-canvas>
<button class="close-button" aria-label="Close menu" type="button" data-close>
<span aria-hidden="true">×</span>
</button>
<ul class="vertical menu" data-accordion-menu style="max-width: 250px">
<li>
<a href="#">Item 1</a>
<ul class="menu vertical nested">
<li>
<a href="#">Item 1A</a>
<ul class="menu vertical nested">
<li><a href="#">Item 1Ai</a></li>
<li><a href="#">Item 1Aii</a></li>
<li><a href="#">Item 1Aiii</a></li>
</ul>
</li>
<li><a href="#">Item 1B</a></li>
<li><a href="#">Item 1C</a></li>
</ul>
</li>
<li>
<a href="#">Item 2</a>
<ul class="menu vertical nested">
<li><a href="#">Item 2A</a></li>
<li><a href="#">Item 2B</a></li>
</ul>
</li>
<li><a href="#">Item 3</a></li>
</ul>
</div>
<div class="off-canvas-content" data-off-canvas-content>
<p>
No weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall prosperNo weapon fashion against me shall
</p>
</div>
</div>
</div>
<div class="cell shrink footer">
<h3>Here's my footer</h3>
</div>
</div>
我在做什么错了。
答案 0 :(得分:0)
我希望我了解您在这里做什么,但是您可以为此使用flexbox。
.off-canvas-wrapper {
display: flex;
height: 100%;
overflow-y: scroll;
}
这将使边栏最大高度不滚动。 “ display:flex”将使子元素与彼此的高度不相关(因为缺少更好的单词),而只会采用自己的高度。
overflow-y会给div一个滚动条,但前提是高度超过可见窗口。