Skip to content Skip to sidebar Skip to footer

How Do I Make A Slated Rounded Border On A Html Element?

Basically, I need to make a header, styled like this: Is there a full css way, or do I need to use background-images?

Solution 1:

Yes, you can do it using only CSS, but it's not easy and the result is... well, ugly. You might want to check this as well: CSS for inverted curved tabs

EDIT: I got a better idea today, check this http://dabblet.com/gist/2762234

The CSS is as follows:

h1 {
    min-width: 150px;
    height: 30px;
    margin: 0;
    /**border: solid 2px #979797;/**/
    border-bottom: none;
    border-radius: 8px 0 0 0;
    box-shadow: -2px -2px 2px #a5a5b1;
    display: inline-block;
    position: relative;
    background: linear-gradient(#e8e8ea, #f8f8fa);
}
h1:before {
    /**top: -2px;/**/
    /**/top: 0;/**/
    right: -23px;
    width: 30px;
    height: 30px;
    border-radius: 0 8px 0 0;
    /**border: solid 2px #979797;/**/
    border-left: none;
    border-bottom: none;
    box-shadow: 2px -2px 2px #a5a5b1;
    /** outline: solid 1px red; /* uncomment this to check position */
    transform: skewX(30deg);
    position: absolute;
    background: linear-gradient(#e8e8ea, #f8f8fa);
    content: '';
}
h1:after {
    right: -44px;
    /**bottom: 0;/**/
    /**/bottom: 2px;/**/
    width: 16px;
    height: 8px;
    /**border: solid 2px #979797;/**/
    border-top: none;
    border-right: none;
    border-radius: 0 0 0  8px;
    box-shadow: inset 2px -2px 2px #a5a5b1, -4px 4px 2px #f8f8fa;
    /** outline: solid 1px red; /* uncomment this to check position */
    transform: skewX(30deg);
    position: absolute;
    content: '';
}
div {
    min-height: 130px;
    margin-top: -7px;
    /**border: solid 2px #979797;/**/
    border-radius: 0 8px 0 0;
    box-shadow: -2px -2px 2px #a5a5b1, 2px -2px 2px #a5a5b1;
    background: linear-gradient(#f8f8fa, #f6f6f8);
}

It can be made to look prettier, but that would require a fixed width for the heading and a pseudo-element on the div.


Solution 2:

You can probably achieve this by using a couple of elements stacked over eachother.
I don't think that is something you would want for production, so my advice would be to go for the background image.


Post a Comment for "How Do I Make A Slated Rounded Border On A Html Element?"