0

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/

morthemex
  • 5
  • 3
  • border-radius does not work with border-image see e.g. https://stackoverflow.com/questions/62052199/border-radius-with-border-image and related question. – A Haworth Apr 24 '22 at 20:55

1 Answers1

0

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>
chrwahl
  • 8,675
  • 2
  • 20
  • 30
  • To be honest, I don't really think there is such a thing as cheating in web development. There certainly is best practice, but I think this works perfectly well for what I'm working on. Thanks very much for the idea! – morthemex Apr 29 '22 at 15:35