我有这个SVG:
* {
background: #e1e1e1;
}Run Code Online (Sandbox Code Playgroud)
<svg class="decor" height="100%" preserveaspectratio="none" version="1.1" viewbox="0 0 100 100" width="100%" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0 L100 100 L0 100" stroke-width="0"></path>
</svg>Run Code Online (Sandbox Code Playgroud)
如何旋转180度?!
Har*_*rry 24
只需使用元素类型选择器并将transform: rotate(180deg)属性添加到它,就像在下面的代码片段中一样.
* {
background: #e1e1e1;
}
svg {
transform: rotate(180deg);
}Run Code Online (Sandbox Code Playgroud)
<svg class="decor" height="100%" preserveaspectratio="none" version="1.1" viewbox="0 0 100 100" width="100%" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0 L100 100 L0 100" stroke-width="0"></path>
</svg>Run Code Online (Sandbox Code Playgroud)
或者,如果您只想旋转path而不是svg自己旋转transform-origin,请在下面的代码段中添加类似内容:
* {
background: #e1e1e1;
}
path {
transform: rotate(180deg);
transform-origin: 50% 50%;
}Run Code Online (Sandbox Code Playgroud)
<svg class="decor" height="100%" preserveaspectratio="none" version="1.1" viewbox="0 0 100 100" width="100%" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0 L100 100 L0 100" stroke-width="0"></path>
</svg>Run Code Online (Sandbox Code Playgroud)
And*_*Ana 16
内联你会这样做:
例如。在你的例子中:
<svg class="decor" transform="scale(-1 1)" height="100%" preserveaspectratio="none" version="1.1" viewbox="0 0 100 100" width="100%" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0 L100 100 L0 100" stroke-width="0"></path>
</svg>
Run Code Online (Sandbox Code Playgroud)