Safari 嵌套 flex 问题
Safari nested flex issue
嵌套的 flex 框与兄弟 flex-grow : 1 和 overflow-y : auto 不工作正如 Safari 中预期的那样 [我的版本 13.1 (14609.1.20.111.8)]。这在 Chrome 中再次有效。附上这两项的屏幕截图以及最小的可重现代码块。
如果我们给 flex-basis 一个固定大小:[n]px 给第二个 child.. 它工作正常。但我们不能总是期望给出它,因为第二项中的内容是动态的。在下面的代码块中,它给出了一个最小的可重现用例。
.parent {
flex-direction: column;
display: flex;
background-color: #CCC;
padding: 8px;
height: 150px;
font-size: 16px;
}
.fixedChild {
display: flex;
padding: 10px;
justify-content: space-between;
flex-basis: auto;
}
.growingChild {
overflow-y: auto;
flex-grow: 1;
}
/*! CSS Used from: Embedded */
.fancyButton {
background-color: transparent;
border: 1px solid transparent;
border-color: #0076D1;
border-radius: 15px;
color: #0076D1;
height: 50px;
justify-content: center;
outline: none;
padding: 0 8px;
}
<div class="parent">
<div class="growingChild">
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
</div>
<div class="fixedChild">
<button class="fancyButton" type="button">button 1</button>
<button class="fancyButton" type="button">button 1</button>
<button class="fancyButton" type="button">button 1</button>
</div>
</div>
这并没有解决潜在的不一致问题,而是将最后一个子项(弹性项目)设置为:
flex-shrink: 0;
似乎使 Safari 和 Chrome 的行为相同,其中 flex 容器负责按钮的高度以及不断增长的 flex 项目兄弟。不确定谁对谁错,但我觉得也许是 Safari?
嵌套的 flex 框与兄弟 flex-grow : 1 和 overflow-y : auto 不工作正如 Safari 中预期的那样 [我的版本 13.1 (14609.1.20.111.8)]。这在 Chrome 中再次有效。附上这两项的屏幕截图以及最小的可重现代码块。
如果我们给 flex-basis 一个固定大小:[n]px 给第二个 child.. 它工作正常。但我们不能总是期望给出它,因为第二项中的内容是动态的。在下面的代码块中,它给出了一个最小的可重现用例。
.parent {
flex-direction: column;
display: flex;
background-color: #CCC;
padding: 8px;
height: 150px;
font-size: 16px;
}
.fixedChild {
display: flex;
padding: 10px;
justify-content: space-between;
flex-basis: auto;
}
.growingChild {
overflow-y: auto;
flex-grow: 1;
}
/*! CSS Used from: Embedded */
.fancyButton {
background-color: transparent;
border: 1px solid transparent;
border-color: #0076D1;
border-radius: 15px;
color: #0076D1;
height: 50px;
justify-content: center;
outline: none;
padding: 0 8px;
}
<div class="parent">
<div class="growingChild">
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
</div>
<div class="fixedChild">
<button class="fancyButton" type="button">button 1</button>
<button class="fancyButton" type="button">button 1</button>
<button class="fancyButton" type="button">button 1</button>
</div>
</div>
这并没有解决潜在的不一致问题,而是将最后一个子项(弹性项目)设置为:
flex-shrink: 0;
似乎使 Safari 和 Chrome 的行为相同,其中 flex 容器负责按钮的高度以及不断增长的 flex 项目兄弟。不确定谁对谁错,但我觉得也许是 Safari?