Fit <svg> to the size of <object> container

前端 未结 2 1910
死守一世寂寞
死守一世寂寞 2020-12-29 06:24

I have this markup:

#widget1 {
    height:100px;
    width:200px;
}

相关标签:
2条回答
  • 2020-12-29 06:48

    Try to add: width: XXXpx !important; height: XXXpx !important;

    0 讨论(0)
  • 2020-12-29 07:14

    This is answered (with examples) in the svg primer.

    tl;dr summary:

    • remove 'width' and 'height' attributes on the svg root, and add a 'viewBox' attribute with the value "0 0 w h", where w and h are the absolute values usually found in the width and height attributes (note that percentages and other units aren't allowed in the viewBox attribute)
    0 讨论(0)
提交回复
热议问题