Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make corners angled like this using css?

Tags:

css

Here is an image of what I'm talking about:

corners

Is there a way to get the corners like this using css3 or do I have to resort to images? I believe I saw a tutorial on this somewhere but I can't seem to find it.

like image 277
J82 Avatar asked Jun 24 '11 21:06

J82


People also ask

Which CSS properties can you use to create a rounded corner?

The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.


2 Answers

Do you mean something like this demo fiddle?

Angled corners

HTML:

<div class="box">
    <div class="head">
        <div class="like"></div>
        <h3>User927</h3>
    </div>
    <div class="cont">
        <p>Lorem ipsum...</p>
    </div>
    <div class="foot">
        <a href="">More</a>
    </div>   
</div>

CSS:

.box {
    width: 310px;
    position: relative;
}
.head {
    background: black;
    color: white;
}
.cont {
    border-left: 1px solid silver;
    border-right: 1px solid silver;
}
.foot {
    background: lightgray;
    border: 1px solid silver;
    border-bottom-width: 3px;
}
.head:before,
.head:after,
.foot:before,
.foot:after {
    font-size: 0px; 
    content: ".";
    position: absolute;    
}
.head:before {
    border-top: 5px solid white;
    border-right: 5px solid black;
    left: 0;
    top: 0;
}
.head:after {
    border-top: 5px solid white;
    border-left: 5px solid black;
    right: 0;
    top: 0;
}
.foot:before {
    border-bottom: 7px solid white;
    border-right: 7px solid transparent;
    left: 0;
    bottom: 0;
}
.foot:after {
    border-bottom: 7px solid white;
    border-left: 7px solid transparent;
    right: 0;
    bottom: 0;
}

Downside: for IE7 you would need extra span's in the markup because the :after and :before specifiers are not supported, see this revised fiddle.

like image 92
NGLN Avatar answered Oct 07 '22 05:10

NGLN


I've had great luck with jQuery Corners:

http://malsup.com/jquery/corner/

It can do slanted corners as well as many other varieties, and works well in older browsers too:

like image 2
Seth Avatar answered Oct 07 '22 05:10

Seth