Cut Corners using CSS

后端 未结 15 1440
悲&欢浪女
悲&欢浪女 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 04:09

    I recently cut off the top right corner and overlaid the tabs like folders. Complete code noob, so ignore the shitty code, but I did this by combining a square, a triangle, and a rectangle... This may or may not be a new approach, but hopefully, someone finds it helpful.

    https://i.stack.imgur.com/qFMRz.png

    Here is the HTML:

    
    
        
            
            
             
        
        
            

    Home

    About

    Contact

    Here is the CSS:

    .triangleOne {
        height: 50px;
        width: 40px;
        background: red;
        border-radius: 5px 0px 0px 5px;
        position: absolute;
    }
    
    .triangleOneCut {
        content: '';
        position: absolute;
        top: 0; left: 40px;
        border-top: 10px solid transparent;
        border-left: 10px solid red;
        width: 0;
    }
    
    .triangleOneFill {
        content: '';
        position: absolute;
        top: 10px; left: 40px;
        width: 10px;
        height: 40px;
        background-color: red;
        border-radius: 0px 0px 5px 0px;
    }
    
    .container {
        position: relative;
        height: 50px;
        width: 50px;
        display: inline-block;
        z-index: 3;
    }
    
    .container2 {
        position: relative;
        height: 50px;
        width: 50px;
        display: inline-block;
        left: -10px;
        z-index: 2;
    }
    
    .container3 {
        position: relative;
        height: 50px;
        width: 50px;
        display: inline-block;
        left: -20px;
        z-index: 1;
    }
    
    .blue {
        background-color: blue;
    }
    
    .green {
        background-color: green;
    }
    
    .blueCut {
        border-left: 10px solid blue;
    }
    
    .greenCut {
        border-left: 10px solid green;
    }
    
    .folders {
        width: 160px;
        height: 50px;
        /* border: 10px solid white; */
        margin: auto;
        padding-left: 25px;
        margin-top: 100px;
    }
    
    .folderNames {
        text-align: right;
        padding-left: 2px;
        color: white;
        margin-top: 1.5px;
        font-family: monospace;
        font-size: 6.5px;
        border-bottom: double 1.5px white;
    }
    

提交回复
热议问题