Search code examples
csshtmlpseudo-elementpseudo-class

how to get transparent for the div?


Does CSS gives any option to show background image at the corner a transparent.

instead of showing white background in (DEMO)

avoid white area

enter image description here

#octagon {
    width: 100px;
    height: 100px;
    background: red;
    position: relative;
    margin: 50px auto 0;
}

#octagon:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    border-bottom: 29px solid red;
    border-left: 29px solid red;
    border-right: 29px solid #eee;
    width: 42px;
    height: 0;
}

http://jsfiddle.net/L8JUJ/4/


Solution

  • Working Fiddle

    Made small changes and adjustments in margins.

    CSS:

    body{
        background: url(http://placehold.it/350x150&text=FooBar1) repeat;
    }
    #octagon {
        width: 100px;
        height: 71px;
        background: red;
        position: relative;
        margin: 99px 10px 0px 100px;
    }
    
    #octagon:before {
        content: "";
        position: absolute;
        top: -29px;
        left: 0;
        border-bottom: 29px solid red;
        border-left: 29px solid red;
        border-right: 29px solid transparent;
        width: 42px;
        height: 0;
    }