Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make div with bottom triangle

I have been trying to do the white shape with a div:

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

how do I get the diagonal shapes of the bottom of the div?

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

thank you

Edit: just forget the bg behind the div, I want to make the div with the diagonal borders, not with the help of the bg because it is in the top layer

like image 783
codek Avatar asked Sep 03 '12 16:09

codek


People also ask

How do I make a triangle in a div?

Approach: To create the triangle, in the HTML part we have to just add a single div for each triangle. The concept is to create a box with no width or height. The width of the border determines the Triangle's actual width and height.

How do I make a DIV at the bottom?

Set the position of div at the bottom of its container can be done using bottom, and position property. Set position value to absolute and bottom value to zero to placed a div at the bottom of container.

How do I place a DIV at the bottom without absolute?

Without using position: absolute , you'd have to vertically align it. You can use vertical-align: bottom which, according to the docs: The vertical-align CSS property specifies the vertical alignment of an inline or table-cell box.


1 Answers

You can also use borders and the :after pseudo selector: 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've colored the tip for easy identification of the borders. Play around the border widths on the last 3 lines to get the tip you want.

Edit.:

Reference for compability: http://caniuse.com/css-gencontent

Edit 2:

In exchange for semantics, you can get it more crossbrowser you can place the stle on a inner element instead of on the :after pseudo selector.

like image 198
Ricardo Souza Avatar answered Sep 21 '22 18:09

Ricardo Souza