In my svg
element, I have a text
element positioned after two rect
elements.
<svg id="floor-plan" width="300" height="100">
<rect width="300" height="100" fill="white"/>
<rect width="50" height="50" fill="green"/>
<text x="10" y="10" dy="1.5em" fill="white">dfdklsfjsadgkldsjfglkdsjfklögj</text>
The size of the second rect
is smaller than the text
element.
I am looking for a way to change the color of the text
element if it extends outside the boundary of the first rect
and overlaps with the green rect
.
Any suggestions on how to achieve this?
Thank you in advance.
This question has been addressed in a similar context here: Change SVG color based on current background