如何使用内容从底部填充svg路径的动画?

时间:2017-02-15 09:49:09

标签: css svg

我正在寻找一种用于使用颜色填充svg路径的跨浏览器解决方案。以下解决方案适用于Chrome,但面临其他浏览器的问题。即Edge,Firefox,Opera和safari

我还想不使用clip-mask

  svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%)
  }
  
  .v1 {
    fill: #d81920;
  }
  
  .v1.stroke {
    fill: rgba(0, 0, 0, 0);
    stroke: #d81920;
    stroke-width: 7
  }
  
  .clip {
    animation: slide 5s forwards cubic-bezier(0.47, 0, 0.745, 0.715)
  }
  
  @keyframes slide {
    100% {
      transform: translateY(-100%);
    }
  }
<svg height="200px" width="200px" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1122.52 793.70667"
  height="793.70667" width="1122.52" xml:space="preserve" version="1.1">

            <defs>
                <clipPath id="cut">
                    <rect x="100" y="670" width="850" height="600" class="clip"/>
                </clipPath>
            </defs>


            <g transform="matrix(1.3333333,0,0,-1.3333333,0,793.70667)" >
                <g transform="translate(306.5302,96.3909)">
                    <path class="v1 stroke" d="M 0,0 H -161.076 L -47.644,402.498 H 113.432 Z" ></path>
                </g>
                <g transform="translate(583.0042,96.3909)">
                    <path class="v1 stroke" d="M 0,0 H -161.076 L -47.644,402.498 H 113.432 Z" ></path>
                </g>
            </g>
            <g clip-path="url(#cut)">
                <g transform="matrix(1.3333333,0,0,-1.3333333,0,793.70667)" >
                    <g transform="translate(306.5302,96.3909)">
                        <path class="v1" d="M 0,0 H -161.076 L -47.644,402.498 H 113.432 Z" ></path>
                    </g>
                    <g transform="translate(583.0042,96.3909)">
                        <path class="v1" d="M 0,0 H -161.076 L -47.644,402.498 H 113.432 Z" ></path>
                    </g>
                </g>
            </g>
</svg>

0 个答案:

没有答案