CSS:使div可调整大小

时间:2016-12-23 11:49:08

标签: html css layout resize flexbox

假设我有一个flex布局,并希望使其可调整大小。

我希望能够通过水平拖动边框来调整一个div的大小。

看看这个Fiddle

HTML



#main {
  display: flex;
  justify-content: space-between;
  height: 100vh;
  .flex {
    width: 100%;
    &:nth-child(2) {
      background: red;
      overflow: auto; resize: horizontal;
    }
  }
}

<div id="main">
  <div class="flex">ABC</div>
  <div class="flex">
    DEF
  </div>
  <div class="flex">GHI</div>
</div>
&#13;
&#13;
&#13;

我该怎么做?

2 个答案:

答案 0 :(得分:1)

检查这个plunkr

https://plnkr.co/edit/sxs6RLXVV6REzQnipfgj?p=preview

$( "#second" ).resizable();

答案 1 :(得分:1)

您应该遵循此代码

#main {
    display: flex;
    justify-content: space-between;
    height: 100vh;
    .flex {
        width: 100%;
        &:nth-child(2) {
            background: red;
            resize: both;
            overflow: auto;
        }
    }
}