Make a div with a lower triangle

I am trying to make a white shape using a div:

http://sircat.net/joomla/sircat/mies/2.png

How do I get the diagonal bottom shapes of a div?

I have this for a div: width: 620 pixels; height: 440px; background-color: white;

Thank you

Edit: just forget bg for the div, I want to make a div with diagonal borders, not using bg, because it is in the top layer

+5
source share
2 answers

You can also use borders and a pseudo-selector :after: http://jsfiddle.net/qQySU/

#pointed {
    position: relative;
    margin: 0 auto;
    width: 200px;
    height: 200px;
    background-color: white;
}

#pointed:after,
#pointed::after {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -50%;
    content: '';
    width: 0;
    height: 0;
    border-top: solid 150px red;
    border-left: solid 100px transparent;
    border-right: solid 100px transparent;
}

I painted the tip for easy border identification. Play around the borders of width on the last 3 lines to get the advice you need.

Edit :.

: http://caniuse.com/css-gencontent

2:

crossbrowser, stle , - :after.

+12

( ): CSS linear-gradient http://dabblet.com/gist/3610406

HTML:

<div class='box'>Text goes here...</div>

CSS

.box {
    width: 26em;
    min-height: 31em;
    padding: 1em;
    outline: solid 1px lightblue;
    margin: 0 auto;
    background: linear-gradient(45deg, dimgrey 47%, black 50%, transparent 50%) 
                    no-repeat 0 100%, 
                linear-gradient(-45deg, dimgrey 47%, black 50%, transparent 50%) 
                    no-repeat 100% 100%;;
    background-size: 50% 14em;
}

: a box-shadow: http://dabblet.com/gist/3610548

HTML:

<div class='box'>text goes here... hover me ;)</div>

CSS

html { background: darkgrey; }
.box {
    box-sizing: border-box;
    position: relative;
    width: 20em;
    height: 20em;
    padding: 1em;
    margin: 3em auto 0;
    background: white;
}
.box:before {
    position: absolute;
    right: 14.65%; /* 50% - 35.35% */ bottom: -35.35%; /* half of 70.71% */
    width: 70.71%; /* 100%*sqrt(2)/2 */
    height: 70.71%;
    box-shadow: 2px 2px 1px dimgrey;
    transform: rotate(45deg);
    background: white;
    content: '';
}
.box:hover, .box:hover:before {
    background: plum;
}
+5

All Articles