【发布时间】:2013-01-16 05:45:50
【问题描述】:
我有一个 SVG 元素,里面有很多元素。 SVG 元素有一个视图框,因此您可以按下缩放按钮,元素看起来更大或更小。效果很好。现在的问题是,当元素溢出父 SVG 元素时,不会出现 ScrollBars。
示例:
<div width="100%" height="100%">
<svg height="100%" width="100%" style="overflow-x: auto; overflow-y: auto; "viewBox="0 0 793 1122">
<g>
...
<line y2="44.9792mm" y1="44.9792mm" x1="197.203mm" x2="12.7028mm"></line>
<line y2="44.9792mm" y1="44.9792mm" x1="197.203mm" x2="12.7028mm"></line>
<text x="43.4516mm" y="52.9167mm" style="font-size: 11pt;">S</text>
<rect x="0" width="210mm" y="0" height="297mm"></rect>
...
</g>
</svg>
</div>
//here I set the viewbox after clicking the zoomOut-Button
float width = svg.getViewBox().getBaseVal().getWidth();
float height = svg.getViewBox().getBaseVal().getHeight();
svg.getViewBox().getBaseVal().setHeight((float) (height / 0.9));
svg.getViewBox().getBaseVal().setWidth((float) (width / 0.9));
有人可以帮助我吗? 我将溢出属性放在 svg 和 div 标签中。不工作。
【问题讨论】:
-
不知道几天前我是怎么进入这个页面的,但是看看:carto.net/svg/gui/scrollbar 可能会有帮助
-
我知道这个例子,但他们用 svg/js 创建了自己的滚动条,而不是 html/css 默认滚动条。