【发布时间】:2019-08-18 08:18:20
【问题描述】:
codepen 显示了我的设置。当 flex-direction 设置为 row 时,svg 应该与父级一起缩放。
希望你能帮到我
flex-direction: column;
编辑:复制codepen代码
<div class="grandparent">
<div class="parent">
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none"
class="child" width="100%" height="100%">
<line class="top" x1="0" y1="0" x2="300%" y2="0" />
<line class="left" x1="0" y1="100%" x2="0" y2="-200%" />
<line class="bottom" x1="100%" y1="100%" x2="-200%" y2="100%" />
<line class="right" x1="100%" y1="0" x2="100%" y2="300%" />
</svg>
</div>
</div>
.grandparent {
height: 50vh;
width: 50vh;
display: flex;
flex-direction: column;
}
.parent {
flex: auto;
position: relative;
}
svg line {
stroke-width: 3;
stroke: #000;
fill: none;
}
【问题讨论】:
-
什么是
flex:auto?我想你想要flex:1 -
弹性:自动=弹性增长:1;弹性收缩:1;弹性基础:自动;