0
为什么在SVG元素上设置viewbox属性会弄乱高度并导致溢出?我怎样才能防止呢?SVG ViewBox Breaks高度
.parent {
width: 500px;
height: 500px;
background-color: green;
display: flex;
flex-direction: column;
}
.child {
flex-grow: 1;
background-color: yellow;
margin: 10px;
}
<div class="parent">
<h1>testa</h1>
<div class="child">
<svg viewbox="0 0 40 40">
<rect x="10" y="10" width="30" height="30" fill="red" />
</svg>
</div>
</div>
如果你想防止溢出显示你可以添加'overflow-y:hidden'到**。parent ** div。 – Arthur
我宁愿如果svg不占用太多空间,而是缩放其内容。 – Henning
这也会发生在图像上,它并不是SVG和viewBox属性的使用。 – hungerstar