SVG D3 Scrolling with max height

2019-08-03 08:25发布

I have a very simple ui with bunch of rect added on a scrolling div container with max-height.

https://jsfiddle.net/bikrantsharma/eqnnd84v/

.legend-main-div {
  padding: 2%;
  height: 150px;
  overflow-y: scroll;
  border: 1px solid blue;
}

it is only showing only few svg items. how can i show all the items in the container with the same max-height?

标签: jquery d3.js svg
1条回答
神经病院院长
2楼-- · 2019-08-03 09:13

You are correct in setting the height using a percentage unit. However, the view box is wrongly named: it is viewBox, not viewbox.

.attr('viewBox', '0 0 500 ' + responsiveDivHeight + '')

Here is your updated fiddle: https://jsfiddle.net/ahafvqzw/

查看更多
登录 后发表回答