Search code examples
csssvgcss-animationsbordersvg-animate

Animated SVG border-image not honoring border-radius


I'm trying to make an animated border radius via using an SVG with border-image, and round it out with border-radius. I have overflow: hidden; but the border doesn't seem to be affected by this property. I'll give the current code below, and an example of the border styles in a JSFiddle. Any help is appreciated!

    margin: 0 auto;
    height: 80vh;
    font-size: 3vw;
    overflow: hidden;
    border: 5px solid;
    border-image: url(../images/borderAnimation.svg) 5 stretch;
    border-radius: 15px;
    background-color: rgb(70, 70, 70);

JSFiddle: https://jsfiddle.net/madaley/vfunmsr7/


Solution

  • I know this is kind of cheating, but if you could have nested elements then the parent could have a background and the child could mask of the background with a color:

    div.wrapper {
      width: 300px;
      height: 200px;
      border-radius: 10px;
      padding: 5px;
      background-image: url(https://www.public.asu.edu/~madaley1/images/borderAnimation.svg);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    div.wrapper>div {
      width: 100%;
      height: 100%;
      border-radius: 5px;
      box-sizing: border-box;
      background: white;
    }
    <div class="wrapper">
      <div></div>
    </div>