Is there a way to align an object (say, rect) in SVG, relative to the right border of a group or the document? I want the object to keep its size, when I increase the whole document width, but increase X position to stay right-aligned.
Regards,
Is there a way to align an object (say, rect) in SVG, relative to the right border of a group or the document? I want the object to keep its size, when I increase the whole document width, but increase X position to stay right-aligned.
Regards,
I was looking for a way to float a < g> element to the right of a svg file with width=100%. So one could scale the image and my < g> element would stick to the right without beeing scaled.
Here is what I found out:
The trick is to use a < svg> tag, where you place your element, that you want to stick to the right border. Then you tell the < svg>-tag not to scale the inner elements and to move them so, that the x values are at their maximum and y at minimum (xMaxYMin)
In the same way you can center it...
source: http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute
I had the same question and initially liked kulpae's answer. The problem for me, though, was that I'm trying to make a scroller-type interface in SVG with a left-aligned button for scrolling left and a right-aligned button for scrolling right, and the inner (viewBoxed) svg in kulpae's example would take the entire width of the scroller, therefore obscuring the content of the scroller from receiving click events.
My solution used a 100% x-positioned nested svg element with a negative x-positioned element for the button:
Necromancing.
The various aligns:
top-left
top-right:
left-bottom
right-bottom
Example: