Flexbox溢出不会扩展Chrome中的父容器

时间:2017-04-27 19:12:39

标签: html css css3 flexbox overflow

我使用Flexboxes构建了一个树视图,但我无法在Chrome中使用该布局。溢出不起作用并破坏布局。

在Firefox / IE / Edge中,下面的代码片段可以正常工作,但需要溢出。

在Firefox中使用它的屏幕:

Screen of it working in Firefox

但在Chrome中,它会将其显示在此处的代码段中。如何让溢出像在FF / IE中一样工作?



/* WorkPackage Treeview */

.flex-tree,
.flex-tree2,
.flex-tree-content,
.flex-tree-content2,
.flex-tree-bottom,
.flex-tree-parent,
.flex-tree-children,
.flex-tree-child-button {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

.flex-tree,
.flex-tree2,
.flex-tree-content,
.flex-tree-content2,
.flex-tree-parent {
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
}

.flex-tree {
  min-width: 240px;
  max-width: 245px;
  min-height: 180px;
  max-height: 180px;
  position: absolute;
  border-style: solid;
  border-width: 1px;
  z-index: 100;
}

.flex-tree2 {
  min-width: 240px;
  max-width: 245px;
  min-height: 380px;
  max-height: 380px;
  position: absolute;
  border-style: solid;
  border-width: 1px;
  z-index: 100;
}

.flex-tree-content {
  min-height: 150px;
  max-height: 150px;
  background-color: White;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  overflow-y: scroll;
}

.flex-tree-content2 {
  min-height: 350px;
  max-height: 350px;
  background-color: White;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  overflow-y: scroll;
}

.flex-tree-bottom {
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-height: 32px;
  background-color: Gray;
  border-bottom-style: solid;
  border-bottom-width: 1px;
}

.flex-tree-parent {
  margin-left: 20px;
}

.flex-tree-parent>.flex-tree-children:first-child {
  margin-left: 7px;
}

.flex-tree-children {
  -webkit-flex-direction: row-reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
  margin: 3px;
  margin-left: 27px;
  min-width: 101px;
  max-width: 101px;
  min-height: 20px;
  min-height: 20px;
}

.flex-tree-content>.flex-tree-children:first-child {
  margin-top: 15px;
  margin-left: 7px;
}

.flex-tree-content2>.flex-tree-children:first-child {
  margin-top: 15px;
  margin-left: 7px;
}

.flex-tree-child-button {
  width: 16px;
  height: 16px;
  background-image: url('https://cdn2.iconfinder.com/data/icons/bwpx/icons/toggle_minus.gif');
  background-repeat: no-repeat;
  cursor: pointer;
  order: 2;
}

.flex-tree-child {
  text-align: center;
  width: 80px;
  height: 20px;
  background-color: GreenYellow;
  border-style: solid;
  border-width: 1px;
  color: black;
  margin-left: 5px;
  order: 1;
}

.flex-tree-close {
  line-height: 7px;
  width: 75px;
  height: 25px;
  cursor: pointer;
  margin: 3px;
}

<div class="flex-tree" style="left: 50px; top: 50px;">
  <div class="flex-tree-content">
    <div class="flex-tree-children" id="2">
      <div class="flex-tree-child-button" id="2"></div><a class="flex-tree-child" id="2">1</a></div>
    <div class="flex-tree-children" id="6"><a class="flex-tree-child" id="6">1,1</a></div>
    <div class="flex-tree-parent" id="8">
      <div class="flex-tree-children" id="8">
        <div class="flex-tree-child-button" id="8"></div><a class="flex-tree-child" id="8">1,2</a></div>
      <div class="flex-tree-parent" id="19">
        <div class="flex-tree-children" id="19">
          <div class="flex-tree-child-button" id="19"></div><a class="flex-tree-child" id="19">1,2,1</a></div>
        <div class="flex-tree-children" id="26">
          <a class="flex-tree-child" id="26">1,2,1,1</a></div>


      </div>
      <div class="flex-tree-children" id="29"><a class="flex-tree-child" id="29">1,2,2</a></div>
      <div class="flex-tree-children" id="30"><a class="flex-tree-child" id="30">1,2,3</a></div>
    </div>
    <div class="flex-tree-children" id="9"><a class="flex-tree-child" id="9">1,3</a></div>
    <div class="flex-tree-children" id="23"><a class="flex-tree-child" id="23">1,4</a></div>
    <div class="flex-tree-children" id="24"><a class="flex-tree-child" id="24">New task</a></div>
  </div>
  <div class="flex-tree-bottom">
    <button class="flex-tree-close">Close</button>
  </div>
</div>

<div class="flex-tree2" style="left: 400px; top: 50px;">
  <div class="flex-tree-content2">
    <div class="flex-tree-children" id="2">
      <div class="flex-tree-child-button" id="2"></div><a class="flex-tree-child" id="2">1</a></div>
    <div class="flex-tree-children" id="6"><a class="flex-tree-child" id="6">1,1</a></div>
    <div class="flex-tree-parent" id="8">
      <div class="flex-tree-children" id="8">
        <div class="flex-tree-child-button" id="8"></div><a class="flex-tree-child" id="8">1,2</a></div>
      <div class="flex-tree-parent" id="19">
        <div class="flex-tree-children" id="19">
          <div class="flex-tree-child-button" id="19"></div><a class="flex-tree-child" id="19">1,2,1</a></div>
        <div class="flex-tree-children" id="26">
          <a class="flex-tree-child" id="26">1,2,1,1</a></div>


      </div>
      <div class="flex-tree-children" id="29"><a class="flex-tree-child" id="29">1,2,2</a></div>
      <div class="flex-tree-children" id="30"><a class="flex-tree-child" id="30">1,2,3</a></div>
    </div>
    <div class="flex-tree-children" id="9"><a class="flex-tree-child" id="9">1,3</a></div>
    <div class="flex-tree-children" id="23"><a class="flex-tree-child" id="23">1,4</a></div>
    <div class="flex-tree-children" id="24"><a class="flex-tree-child" id="24">New task</a></div>
  </div>
  <div class="flex-tree-bottom">
    <button class="flex-tree-close">Close</button>
  </div>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:4)

flex-shrink: 0

上使用.flex-tree-parent

/* WorkPackage Treeview */

.flex-tree,
.flex-tree2,
.flex-tree-content,
.flex-tree-content2,
.flex-tree-bottom,
.flex-tree-parent,
.flex-tree-children,
.flex-tree-child-button {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

.flex-tree,
.flex-tree2,
.flex-tree-content,
.flex-tree-content2,
.flex-tree-parent {
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
}

.flex-tree {
  min-width: 240px;
  max-width: 245px;
  min-height: 180px;
  max-height: 180px;
  position: absolute;
  border-style: solid;
  border-width: 1px;
  z-index: 100;
}

.flex-tree2 {
  min-width: 240px;
  max-width: 245px;
  min-height: 380px;
  max-height: 380px;
  position: absolute;
  border-style: solid;
  border-width: 1px;
  z-index: 100;
}

.flex-tree-content {
  min-height: 150px;
  max-height: 150px;
  background-color: White;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  overflow-y: scroll;
}

.flex-tree-content2 {
  min-height: 350px;
  max-height: 350px;
  background-color: White;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  overflow-y: scroll;
}

.flex-tree-bottom {
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-height: 32px;
  background-color: Gray;
  border-bottom-style: solid;
  border-bottom-width: 1px;
}

.flex-tree-parent {
  margin-left: 20px;
  flex-shrink: 0;
}

.flex-tree-parent>.flex-tree-children:first-child {
  margin-left: 7px;
}

.flex-tree-children {
  -webkit-flex-direction: row-reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
  margin: 3px;
  margin-left: 27px;
  min-width: 101px;
  max-width: 101px;
  min-height: 20px;
  min-height: 20px;
}

.flex-tree-content>.flex-tree-children:first-child {
  margin-top: 15px;
  margin-left: 7px;
}

.flex-tree-content2>.flex-tree-children:first-child {
  margin-top: 15px;
  margin-left: 7px;
}

.flex-tree-child-button {
  width: 16px;
  height: 16px;
  background-image: url('https://cdn2.iconfinder.com/data/icons/bwpx/icons/toggle_minus.gif');
  background-repeat: no-repeat;
  cursor: pointer;
  order: 2;
}

.flex-tree-child {
  text-align: center;
  width: 80px;
  height: 20px;
  background-color: GreenYellow;
  border-style: solid;
  border-width: 1px;
  color: black;
  margin-left: 5px;
  order: 1;
}

.flex-tree-close {
  line-height: 7px;
  width: 75px;
  height: 25px;
  cursor: pointer;
  margin: 3px;
}
<div class="flex-tree" style="left: 50px; top: 50px;">
  <div class="flex-tree-content">
    <div class="flex-tree-children" id="2">
      <div class="flex-tree-child-button" id="2"></div><a class="flex-tree-child" id="2">1</a></div>
    <div class="flex-tree-children" id="6"><a class="flex-tree-child" id="6">1,1</a></div>
    <div class="flex-tree-parent" id="8">
      <div class="flex-tree-children" id="8">
        <div class="flex-tree-child-button" id="8"></div><a class="flex-tree-child" id="8">1,2</a></div>
      <div class="flex-tree-parent" id="19">
        <div class="flex-tree-children" id="19">
          <div class="flex-tree-child-button" id="19"></div><a class="flex-tree-child" id="19">1,2,1</a></div>
        <div class="flex-tree-children" id="26">
          <a class="flex-tree-child" id="26">1,2,1,1</a></div>


      </div>
      <div class="flex-tree-children" id="29"><a class="flex-tree-child" id="29">1,2,2</a></div>
      <div class="flex-tree-children" id="30"><a class="flex-tree-child" id="30">1,2,3</a></div>
    </div>
    <div class="flex-tree-children" id="9"><a class="flex-tree-child" id="9">1,3</a></div>
    <div class="flex-tree-children" id="23"><a class="flex-tree-child" id="23">1,4</a></div>
    <div class="flex-tree-children" id="24"><a class="flex-tree-child" id="24">New task</a></div>
  </div>
  <div class="flex-tree-bottom">
    <button class="flex-tree-close">Close</button>
  </div>
</div>

<div class="flex-tree2" style="left: 400px; top: 50px;">
  <div class="flex-tree-content2">
    <div class="flex-tree-children" id="2">
      <div class="flex-tree-child-button" id="2"></div><a class="flex-tree-child" id="2">1</a></div>
    <div class="flex-tree-children" id="6"><a class="flex-tree-child" id="6">1,1</a></div>
    <div class="flex-tree-parent" id="8">
      <div class="flex-tree-children" id="8">
        <div class="flex-tree-child-button" id="8"></div><a class="flex-tree-child" id="8">1,2</a></div>
      <div class="flex-tree-parent" id="19">
        <div class="flex-tree-children" id="19">
          <div class="flex-tree-child-button" id="19"></div><a class="flex-tree-child" id="19">1,2,1</a></div>
        <div class="flex-tree-children" id="26">
          <a class="flex-tree-child" id="26">1,2,1,1</a></div>


      </div>
      <div class="flex-tree-children" id="29"><a class="flex-tree-child" id="29">1,2,2</a></div>
      <div class="flex-tree-children" id="30"><a class="flex-tree-child" id="30">1,2,3</a></div>
    </div>
    <div class="flex-tree-children" id="9"><a class="flex-tree-child" id="9">1,3</a></div>
    <div class="flex-tree-children" id="23"><a class="flex-tree-child" id="23">1,4</a></div>
    <div class="flex-tree-children" id="24"><a class="flex-tree-child" id="24">New task</a></div>
  </div>
  <div class="flex-tree-bottom">
    <button class="flex-tree-close">Close</button>
  </div>
</div>

相关问题