JSFiddle - React, Tailwind, and code Playground

border-radius vs overflow

by Csaba Hellinger

HTML

<div class="parent">
    <div class="child"></div>
    <div class="cover"></div>
</div>

CSS

.parent {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    background-color: silver;
    overflow: hidden;
    padding: 2px;
    position: relative;
    z-index: 1;
}
.child {
    width: 200px;
    height: 30px;
    background-color: red;    
    position: absolute;
    top: 40%;
    left: 50%;
    transform-origin: left;
    transform: rotate(45deg);
    animation: spin 5s infinite linear;    
}
.cover {
    background-color: white;
    width: 100%;
    height: 100%;
    //opacity: 0.9;
    border-radius: 20px;
    position: relative;
}
@keyframes spin {
    from { transform: rotate(0deg);   }
    to   { transform: rotate(360deg); }
}