国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Users can adjust the width of side-by-side divs by dragging them
P粉690200856
P粉690200856 2023-08-28 17:28:25
0
1
581
<p>I have two divs side by side. If there is any simple solution, allow the user to resize the width of both divs by dragging. </p> <p>If the width of one div increases, the width of the other div decreases, keeping the sum of the widths of the two divs unchanged. </p> <p>It would be great if it could be implemented using pure javascript or css. Feel free to add any other items like divs. </p> <p>The codes for the two divs are as follows: </p> <pre class="brush:php;toolbar:false;">.left { float: left; width: 49%; min-height: 50px; border: 2px dashed #f0f } .right { float: right; width: 49%; min-height: 50px; border: 2px dashed #00f }</pre> <pre class="brush:php;toolbar:false;"><div class="right"></div> <div class="left"></div></pre> <p>Thanks for any ideas! </p>
P粉690200856
P粉690200856

reply all(1)
P粉020085599

Out of curiosity, I created a little experiment and discovered using a main flexbox container .wrapper to contain .left and .right elements and make the hard work of Flexbox Mechanism easier to implement.

Two things:

  • When using resize, the property overflow needs to be set to auto to make the handle visible (in Windows Firefox and Chrome/Edge The above test passed).
  • Select a child element that is resizable and has a handle, I chose .left. Because they are children of the flexbox, when using flex: 1(.right) on another element, the flexbox mechanism will make that element Follows the size of the resized element and fills any remaining space.

MDN Reference: resize

/* 用于輕松調(diào)整 .right 大小的彈性盒容器 */
.wrapper { display: flex }

.left, .right {
    /* 初始大小,瀏覽器將記住上次狀態(tài)直到頁面重新加載 */
    width: 50%;
    min-height: 50px; /* 至少要有一些內(nèi)容顯示 */
    min-width : 50px;
}

.left {
    overflow: auto; /* 必須使手柄可見 */
    resize: both;   /* 啟用雙向調(diào)整大小 */
           /* 在單個方向上使用 horizontal/vertical */
}

.right {
    flex: 1; /* 將填充剩余的水平/垂直空間 */
}

/* 美化 */
.left  { border: 2px dashed #f0f }
.right { border: 2px dashed #00f }
<div class="wrapper">
    <div class="left" ></div>
    <div class="right"></div>
</div>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template