Understanding how SVGs function is still a bit unclear to me. I know that the viewBox property plays a role in scaling SVGs, and I have come across advice suggesting not to specify height and width attributes when creating responsive SVGs. While there are similar questions on this topic here, I am seeking a more specific answer due to my limited understanding.
My goal is to create a horizontal SVG line whose length adjusts based on the webpage's width.
Currently, I have managed to generate a horizontal line using the following code:
<svg id="horizontalLine" width="500" height="5">
<line x1="0" y1="0" x2="500" y2="0"></line>
</svg>
CSS:
#horizontalLine {
stroke: black;
stroke-width: 1;
}
The issue lies in the lack of responsiveness in this line. Ideally, I want the line's "width" to decrease proportionally to the website's width where the SVG is placed, akin to using "vw" as a size unit in CSS.