I’m trying to modify an SVG to increase its height while maintaining its design elements anchored to the bottom. The SVG is an arrow contained within a div. Here’s the current SVG code:
<div class="arrow">
<svg width="99" height="113" viewBox="0 0 99 113" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="0" y1="-2000" x2="0" y2="39.75" stroke="#CECCCC" stroke-width="2"/>
<line x1="0" y1="69.75" x2="0" y2="84.5" stroke="#CECCCC" stroke-width="2"/>
<path id="Shape" d="M98.3536 108.854C98.5488 108.658 98.5488 108.342 98.3536 108.146L95.1716 104.964C94.9763 104.769 94.6597 104.769 94.4645 104.964C94.2692 105.16 94.2692 105.476 94.4645 105.672L97.2929 108.5L94.4645 111.328C94.2692 111.524 94.2692 111.84 94.4645 112.036C94.6597 112.231 94.9763 112.231 95.1716 112.036L98.3536 108.854ZM24.5 109H98V108H24.5V109ZM0 84.5C0 98.031 10.969 109 24.5 109V108C11.5213 108 1 97.4787 1 84.5H0Z" fill="#CECCCC"/>
</svg>
</div>
When I simply increase the height attribute of the SVG, it creates an unwanted empty space at the bottom of the arrow, as shown in the picture.
<svg width="99" height="113" viewBox="0 0 99 413" fill="none" xmlns="http://www.w3.org/2000/svg">
I want to stretch the SVG such that the arrow elongates vertically but remains attached to the bottom of the SVG canvas, without introducing any empty space below it.
How can I adjust the SVG code to achieve this?
2
Answers
In order to stretch the contents of the SVG to match the SVG’s dimensions, add a
preserveAspectRatio
attribute with a value ofnone
to the<svg>
element. Note that this stretching will distort the graphic.I suggest that you split up the SVG in two. Now that you need a "break" on the vertical part with a "No" that would be a good place. It is almost an old school sliding doors technique there the vertical line is height and is cut off in the top.
In the snippet you can see an example (the unordered list) and the two SVGs I used as CSS backgrounds underneath. I skipped the "Yes" arrow.
In any case: Help yourself by drawing the arrow as a path with a stroke, not a path with a fill!