小编fer*_*auz的帖子

向 SVG 元素添加阴影,例如线条

我对 SVG 还很陌生,但我开始使用图表。该图来自这里。我已经搜索了几个小时,但只找到了问题的一半解决方案。正如您从代码片段中看到的,如果您将鼠标悬停在图表上,它就会“发光”。但我希望当我悬停在圆圈和“关节”上时,只有圆圈和“关节”才会发光。

我尝试过的:

  1. 使用常规 CSS 阴影
  2. 使用使图形“发光”的代码,但仅在 g 元素上。
  3. 创建一个单独的 SVG:a) 在主 SVG 中 b) 分别,并将它们与position: absolute. (此后定位工作很奇怪)

我该怎么做才能让圆圈和关节“发光”?

  *{
    box-sizing: border-box;
    margin: 0;
    padding: 0; 
  }

  html, body{
    height: 100%;
    width: 100%;  
  }

  @import url('https://fonts.googleapis.com/css?family=Roboto+Mono:400,500&display=swap');
  body {
    font-family: 'Roboto Mono', monospace;
  }

  .graph .labels.x-labels {
    text-anchor: middle;
  }

  .graph .labels.y-labels {
    text-anchor: end;
  }

  .graph {
    height: 500px;
    width: 800px;
  }

  .graph .grid {
    stroke: #ccc;
    stroke-dasharray: 0;
    stroke-width: 3;
  }

  .labels {
    font-size: …
Run Code Online (Sandbox Code Playgroud)

html css svg

4
推荐指数
1
解决办法
695
查看次数

标签 统计

css ×1

html ×1

svg ×1