How to Code SVG Patterns (Part 1)
ฝัง
- เผยแพร่เมื่อ 17 ธ.ค. 2024
- In this tutorial, we look at the basics of coding an SVG pattern.
Part 1: Alternating pattern (basics)
Part 2: Hexagon pattern (coming soon)
Part 3: Doodle pattern (coming soon)
This series is based on my blog post that takes an in-depth look at creating SVG patterns: svgbackgrounds...
Thanks Matt for shraing, that was really interesting!
Of course, glad you found it interesting!
6:55 I feel as though those black circles would have appeared just fine if you'd replaced the pattern rectangle's fill with "none" instead of "white".
The fill isn't hiding anything, everything that falls outside the pattern tile doesn't show.
You can try it yourself if you'd like:
Good video! Found it interesting, earned a sub.
Thanks!
Thank you!
You're welcome
As with CSS's old 'image-repeat' element, can these Patterns be constrained to repeating only horizontally or vertically?
Not to my knowledge. A workaround would be controlling the height or width of the rectangle with the pattern fill. If the pattern height and rectangle height match, that tile would not repeat vertically, recreating the repeat-x value.
The other thing you could do, if you have access to CSS is to use the CSS background-repeat property and remove the pattern element from the SVG.
Well done.
Thanks!
How do you get the live preview of the .svg? Is it an extension? If so, which one?
It's a VS Code extension called SVG and its by jock.