动画此SVG的麻烦

时间:2016-12-02 17:03:17

标签: css svg

我有一个svg,我试图动画。问题是2倍。当我将鼠标悬停在图标上时,我需要蓝色圆圈变成橙色。另外,我需要svg在完成时动画回原来的状态。

http://codepen.io/dterr009/pen/GNyyQz

HTML和CSS就在这里

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<div class ="new">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  xml:space="preserve">

    <circle class="start" cx="6.9" cy="56.6" r="5.2"/>
    <circle class="st0" cx="57" cy="56.6" r="5.2"/>
    <circle class="st0" cx="6.9" cy="7.4" r="5.2"/>
    <circle class="st0" cx="57" cy="7.4" r="5.2"/>
    <polyline class="st0" points="12.5,56.6 24.5,56.6 24.5,45.6     "/>
    <polyline class="st0" points="52.5,56.6 40.4,56.6 40.4,45.6     "/>
    <polyline class="st0" points="52.5,7.1 40.4,7.1 40.4,18.1   "/>
    <polyline class="st0" points="12.5,7.1 24.5,7.1 24.5,18.1   "/>
    <rect x="19.4" y="18" class="st0" width="25.9" height="27.6"/>
    <circle class="st0" cx="6.9" cy="32" r="5.2"/>
    <circle class="st0" cx="57" cy="32" r="5.2"/>
    <line class="st0" x1="45.4" y1="32" x2="51.3" y2="32"/>
    <line class="st0" x1="13" y1="32" x2="18.8" y2="32"/>
    <circle class="st0" cx="57.1" cy="56.6" r="5.2"/>
    <circle class="st0" cx="57.1" cy="7.4" r="5.2"/>
    <polyline class="st0" points="23,22.5 40.4,22.5 40.4,37.2   "/>
    <polyline class="st0" points="24.5,25.8 24.5,40.4 42,40.4   "/>
</svg>
</div>

<style>
.st0{
  fill:none;
  stroke:#e18a26;
  stroke-width:3;
  stroke-miterlimit:10;
}

svg {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
}

svg:hover{
  animation: dash 2s ease forwards;

}

@keyframes dash {
  to {
    stroke-dashoffset: 0;
    from {stroke: #007bc3;}
  to {stroke: #e18a26;}
  }
}

.start{
  fill:none;
  stroke:#007bc3;
  stroke-width:3;
  stroke-linecap:round;
  stroke-linejoin:round;
  stroke-miterlimit:10;
  stroke-dasharray: 0;
  stroke-dashoffset: 0;
}

.start:hover{
  animation: changecolor .5s ease forwards;
}

@keyframes changecolor {
  from {stroke: #007bc3;}
  to {stroke: #e18a26;}
}
</style>

0 个答案:

没有答案