I am trying to dynamically resize CSS grid layout margins by dragging column separators (or resizing placeholders) with the mouse.
I set resize: horizontal;the element navto resize, and it changes when I drag the small resize marker in the lower right corner of the element, but the width of the adjacent column is not automatically adjusted, which leads to overlap. Here is a broken code handle .
HTML:
<main>
<nav>#1</nav>
<header>#2</header>
<section>#3</section>
</main>
CSS:
main {
display: grid;
border: 3px dotted red;
grid-gap: 3px;
grid-template-columns: 200px 1fr;
grid-template-rows: 100px 1fr;
height: 100%;
}
nav {
grid-column: 1;
grid-row: 1;
grid-row: 1 / span 2;
resize: horizontal;
overflow: scroll;
border: 3px dotted blue;
}
I expected the CSS grid mechanism to automatically handle this case, but obviously this is not the case.
I experimented with resizable jquery-ui, but it doesn't work very well with CSS grids.
, jquery, grid-template-columns/rows: , , , . jquery window, dom.
, , dragstart/dragend?