Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating diagonal border-radius

After searching for a while for a solution for this I've come up with none. What I'm trying to do is create a diagonal border on the first li element's top left corner.. I tried using a solution that involved the background property but it doesn't give me quite what I want. Also it doesn't allow any manipulation of the colors which will be needed later on.

The light blue color should be a border that gets cut (and not a background that gets cut) and the dark grey should be the background of the li.

How can I achieve this via CSS? A JS/Jquery solution would work as well.

EDIT: After seeing a lot of misinterpreted answers to my question I'll clarify it a bit:

The left image is what I have now, the right image should be the result.

example picexpected result

.cal-scheme {
    width: 100%;

    li {
        width: calc(100% / 6);
        height: 150px;
        margin: 0;
        padding: 0;
        border: $thin-blue;
        box-sizing: border-box;
        float: left;

        &:first-child {
            background: linear-gradient(135deg, transparent 20px, $light-blue 0);
            border: 0;
        }
    }
}
like image 847
Chrillewoodz Avatar asked Jan 03 '15 11:01

Chrillewoodz


People also ask

How do you make a diagonal border in CSS?

So, to draw a diagonal line in CSS, we have to simply rotate a normal horizontal line at an angle of + or – 45 degrees. The rotation in CSS is done using the transform property. To create a horizontal line you can either use the border-top or the border-bottom property whichever best suits you.


1 Answers

If I understand question, You need something like this

HTML:

<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

CSS:

body {
    background: darkgrey;
}
li {
    display: block;
    list-style: none;
    width: 200px;
    height: 50px;
    background: lightblue;
    position: relative;
    border: 10px solid lightblue;
    margin-top: 5px;
}

li:first-child:after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border: 15px solid transparent;
    border-right-color: darkgrey;
    position: absolute;
    top: -15px;
    left: -15px;
    transform: rotate(45deg);
}

UPDATE:

You can't achieve with border-radius. Just using css shapes, or hacks like this updated fiddle

HTML:

<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

CSS:

body {
    background: darkgrey;
}
li {
    display: block;
    list-style: none;
    width: 200px;
    height: 50px;
    background: darkgrey;
    position: relative;
    border: 2px solid lightblue;
    margin-top: 5px;
}

li:first-child:after {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    background: darkgrey;
    border-right: 2px solid lightblue;
    position: absolute;
    top: -17px;
    left: -17px;
    transform: rotate(45deg);
}
like image 98
Bogdan Kuštan Avatar answered Sep 30 '22 18:09

Bogdan Kuštan