Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Styling x1, x2, y1, y2 of a svg line using css

I want to make my svg cross smaller by styling it’s line axis ( so y1,y2 etc for all lines).

How can I do this with css?

 <svg viewBox="0 0 24 24">
       <line x1="0" y1="4" x2="24" y2="4" />
       <line x1="0" y1="12" x2="24" y2="12" />
       <line x1="0" y1="20" x2="24" y2="20" />
</svg>

Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use transform: scale(0.5); to ‘scale’ down each line

svg > line {
    transform: scale(0.5);
}
<svg viewBox="0 0 24 24">
       <line x1="0" y1="4" x2="24" y2="4" stroke="black" />
       <line x1="0" y1="12" x2="24" y2="12" stroke="black" />
       <line x1="0" y1="20" x2="24" y2="20" stroke="black" />
</svg>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading