svgpath样式_SVG基本样式属性
svg path 样式
Styles in often come very close to syntax – sometimes exactly the same, often just different enough to cause confusion.
样式通常⾮常接近语法–有时是完全相同的,但有时恰好⾜以引起混淆。
It’s important to note that here we are talking about rules for appearance used in the SVG code itself, not rules that may be applied to the SVG after it has been embedded on the web page. However, if you come to SVG from an understanding of CSS it is useful to compare and contrast style properties between the two:
重要的是要注意,这⾥我们谈论的是SVG代码本⾝中使⽤的外观规则,⽽不是嵌⼊到⽹页中之后可能会应⽤于SVG的规则。 但是,如果您是从CSS的⾓度来学习SVG的,那么在两者之间⽐较和对⽐样式属性将⾮常有⽤:
SVG CSS Equivalent
fill background-color or color, (depending on context)
fill-opacity background-color or color with , (depending on context)
opacity
stroke border-color stroke-width border-thickness stroke-opacity border-color with rx, ry
SVG等效CSS
fill background-color或color , (取决于上下⽂)
fill-opacity background-color或带有 color , (取决于上下⽂)
opacity
stroke border-color
stroke-width border-thickness
stroke-opacity border-color与
rx, ry
The following properties remain the same in styles implemented in SVG or CSS, although the syntax is slightly different for transformations and dimensions in SVG:
下列属性在SVG或CSS中实现的样式中保持不变,尽管SVG中的转换和尺⼨的语法略有不同:
font-family, font-size, font-style, font-variant and font-weight
font-family , font-size , font-style , font-variant和font-weight
width and height
width和height
scale, rotate, skew
scale , rotate , skew
Most of these properties can be applied as part of an SVG style, and if you come from a CSS background, that’s probably
the easiest way to approach the code. I’ve used those that must appear in attribute form in the code
sample below:
这些属性中的⼤多数都可以作为SVG样式的⼀部分来应⽤,如果您来⾃CSS背景,那可能是处理代码的最简单⽅法。 我已经使⽤了必须在
下⾯的代码⽰例中以属性形式显⽰的代码:
<svg width="300" height="170" >
<rect x="10" y="5" rx="15" width="280" height="160" /> <text x="130" y="115" fill="yellow" font-size="100" >SVG</text>
</svg><p>Test paragraph</p>
Produces what you see here:
产⽣您在这⾥看到的内容:
Gradients are substantially different between CSS and SVG, enough to require their own article.
CSS和SVG之间的渐变有很⼤的不同,⾜以需要他们⾃⼰的⽂章。
Note that we don’t have to specify units in SVG, at least in the code I’ve shown here: pixels are always assumed.
请注意,⾄少在我在此处显⽰的代码中,我们不必在SVG中指定单位:始终假定像素。
You should not come away from this article convinced that styles in SVG are simply “CSS done another way”. SVG
provides many controls – as you can see, SVG strokes can include many forms of customized dashes, without any of the complications of CSS3’s – but this should be enough to get you started in styling your SVG content.
您不应偏离本⽂,坚信SVG中的样式只是“ CSS另辟way径”。 SVG提供了许多控件-如您所见,SVG笔划可以包括许多形式的⾃定义破
折号,⽽不会带来CSS3 任何复杂性-但这⾜以使您开始设计SVG内容的样式。
rotate属性svg path 样式
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论