SVG in flexbox messes up height of other elements

前端 未结 1 1707
独厮守ぢ
独厮守ぢ 2021-02-19 05:05

I\'m trying to use a svg element that resizes with the container size in a flexbox, but for some reason it messes up the size of a div (with text) below the svg. (How much chang

1条回答
  •  花落未央
    2021-02-19 05:56

    Your problem with flex-box arises in the usage of the flex shorthand property. You set it to: flex: 1 1 auto, which means: flex-grow: 1; flex-shrink: 1; flex-basis: auto;.

    As you don't want the container having the content text to shrink. You only have to set flex-shrink: 0; to this node. Here is your forked demo: http://codepen.io/anon/pen/GJQqog

    On a side note: In my opinion it's still illegal in html5 to make up new attributes. This is not the reason for the failure, but maybe it would be better to go for data-attributes.

    0 讨论(0)
提交回复
热议问题