I have a #frame DIV of a fixed size. In this #frame is a #scrollable DIV. In the #scrollable are different #item DIVs with absolute position. They exceed the width and height of the #scrollable, so the scrollWidth and scrollHeight gets bigger than its width and height. Now I want to put a SVG as a #background into the #scrollable. The #background should have the same size as the #scrollable. I have defined the SVG with width=100% and height=100%. But this does not match the scrollWidth and scrollHeight. You can see this in the example, because there is still a red area. My aim was to make the #background as big as the #scrollable so that the red area disappears and gets yellow. But it did not work. How to get this working?
#frame {
width: 20em;
height: 10em;
border: 1px solid black;
}
#scrollable {
min-width: 100%;
min-height: 100%;
overflow: scroll;
position: relative;
background: rgb(255,0,0,0.2);
}
#background {
background: rgba(0,255,0,0.2);
}
#item {
position: absolute;
top: 5em;
left: 15em;
min-height: 10em;
min-width: 10em;
background: rgba(0,0,255,0.2);
border: 1px solid rgb(0,0,255);
}
<div id="frame">
<div id="scrollable">
<svg id="background" width="100%" height="100%"></svg>
<div id="item"></div>
</div>
</div>