How to get ScrollBars in SVG?

前端 未结 2 475
一生所求
一生所求 2020-11-27 20:53

I have a SVG-element with a lot of elements inside. The SVG-element has a viewbox, so you can press a zoom-button and the elements appear bigger or smaller. Works well. Now

相关标签:
2条回答
  • 2020-11-27 21:14

    Part of the point of SVG is so that it can scale to fit the screen. However, I think if you want to get something like what you are describing, then you need to set explicit width and height to the svg element. Something like http://jsfiddle.net/qTFxJ/13/ where I set the width and height in pixels to match your viewBox size.

    0 讨论(0)
  • 2020-11-27 21:15

    Try making the SVG element bigger than the div, and let the div handle the overflow using scroll.

    For example, see this jsfiddle, which utilizes the following css:

    div#container {
      height: 400px;
      width: 400px;
      border:2px solid #000;
      overflow: scroll;
     }
    svg#sky {
      height: 100px;
      width: 1100px;
      border:1px dotted #ccc;
      background-color: #ccc;
    }
    
    0 讨论(0)
提交回复
热议问题