【问题标题】:It is possible to give <path> tag a class for css purposes?是否可以为 <path> 标记一个用于 css 目的的类?
【发布时间】:2016-12-11 21:07:50
【问题描述】:

我想在我的 svg 中有两个带有类的路径,这样当我用鼠标悬停 svg 时,我可以切换不透明度。

【问题讨论】:

标签: css html svg


【解决方案1】:

这个问题的答案很容易找到,但无论如何:是的。请参阅https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path

中的全局属性

.shape {
  opacity: .5;
}
<svg width="300px" height="300px" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
  <path class="shape" d="M 100 100 L 300 100 L 200 300 z" fill="orange" stroke="black" stroke-width="5" />
</svg>

【讨论】:

    【解决方案2】:

    是的,你会使用 stroke-opacity 选项。

    【讨论】:

      猜你喜欢
      • 2011-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      相关资源
      最近更新 更多