How to get ScrollBars in SVG?

前端 未结 2 488
一生所求
一生所求 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: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;
    }
    

提交回复
热议问题