How to round-off an image with CSS

前端 未结 1 1838
悲哀的现实
悲哀的现实 2020-12-19 18:57

I\'m trying to recreate an image shape, based purely on CSS. Although it seems to be very hard to make this exact shape, as I can not seem to find CSS properties that could

1条回答
  •  -上瘾入骨i
    2020-12-19 19:55

    Apparently the shape is called an Squircle. After I found that term, it was quite easy to find someone who has already found a solution to creating the shape. I will leave the solution here, if somebody else needs it (definitely not as simple as border-radius):

    Please be aware that I did NOT create this solution, all credit should be given to Mkmueller, https://codepen.io/mkmueller/, for his solution here: https://codepen.io/mkmueller/pen/wRJYKa

    * {
        box-sizing: border-box;
    }
    
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
        margin: 0;
    }
    
    svg.defs {
        position: absolute;
        width: 0;
        height: 0;
    }
    
    .squircle {
        width: 75vmin;
        height: 75vmin;
        background: url(https://source.unsplash.com/user/mkmueller/likes/1000x1000) center / cover, #aaa;
        clip-path: url(#squircle);
    }
    
    .wrapper {
        filter: drop-shadow(0 0 100px rgba(#000, .25));
    }
    
        
            
                
            
        
    
    
    

    0 讨论(0)
提交回复
热议问题