Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - How to make rectangle with pointed sides? [duplicate]

http://nl.tinypic.com/r/jgm90h/8

I would like to know how to make a HTML button tag have the shape in the link above using pure CSS3. Can you guys help me out?

like image 842
t0byman Avatar asked May 14 '14 11:05

t0byman


1 Answers

The trick is to use the pseudo classes :before and :after. Try it like this:

.yourButton {
    position: relative;
    width:200px;
    height:40px;
    margin-left:40px;
    color:#FFFFFF;
    background-color:blue;
    text-align:center;
    line-height:40px;
}

.yourButton:before {
    content:"";
    position: absolute;
    right: 100%;
    top:0px;
    width:0px;
    height:0px;
    border-top:20px solid transparent;
    border-right:40px solid blue;
    border-bottom:20px solid transparent;
}

.yourButton:after {
    content:"";
    position: absolute;
    left: 100%;
    top:0px;
    width:0px;
    height:0px;
    border-top:20px solid transparent;
    border-left:40px solid blue;
    border-bottom:20px solid transparent;
}

JsFiddle: http://jsfiddle.net/VpW5x/

like image 135
Robin Avatar answered Sep 27 '22 17:09

Robin