Cut Corners using CSS

后端 未结 15 1433
悲&欢浪女
悲&欢浪女 2020-11-22 03:34

I\'m looking to \"cut\" the top left corner of a div, like if you had folded the corner of a page down.

I\'d like to do it in pure CSS, are there any methods?

15条回答
  •  失恋的感觉
    2020-11-22 03:50

    You could use linear-gradient. Let's say the parent div had a background image, and you needed a div to sit on top of that with a gray background and a dog-eared left corner. You could do something like this:

    .parent-div { background: url('/image.jpg'); }
    .child-div { 
       background: #333;
       background: linear-gradient(135deg, transparent 30px, #333 0);
    }
    

    See it on CodePen

    Further reading:

    • CSS Gradients on CSS-Tricks
    • Beveled corners & negative border-radius with CSS3 gradients

提交回复
热议问题