Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

border radius top left on triangle using CSS

I have this code

div {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 85px 85px 0 0;
  border-color: #c00000 transparent transparent transparent;
  float: left;
  position: absolute;
  top: 8px;
}
<div></div>

How can I apply border radius top left to above CSS triangle? It seem like impossible here.

like image 830
John St Avatar asked Jan 13 '15 10:01

John St


People also ask

How do you give a border-radius to the top-left corner?

CSS Syntaxborder-top-left-radius: length|% [length|%]|initial|inherit; Note: If you set two values, the first one is for the top border, and the second one for the left border. If the second value is omitted, it is copied from the first. If either length is zero, the corner is square, not rounded.

How do you round the top-left corner in CSS?

The border-top-left-radius CSS property rounds the top-left corner of an element by specifying the radius (or the radius of the semi-major and semi-minor axes) of the ellipse defining the curvature of the corner.

How do you put a radius on a border in CSS?

CSS Syntaxborder-radius: 1-4 length|% / 1-4 length|%|initial|inherit; Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left.


2 Answers

  • First set equal border-width on all the sides
  • Then add border-color to top and left and set right and bottom transparent

div {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 55px;
  border-color: #c00000 transparent transparent #c00000;
  float: left;
  position: absolute;
  top: 8px;
  border-radius: 10px 0px 0px 0px;
}
<div></div>

with box-shadow you can use a pseudo element for giving a box-shadow

div {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 55px;
  border-color: #c00000 transparent transparent #c00000;
  float: left;
  position: absolute;
  top: 8px;
  border-radius: 10px 0px 0px 0px;
}
div:after {
  content: '';
  position: absolute;
  width: 1px;
  height: 155px;
  top: -55px;
  left: 54px;
  transform: rotate(45deg);
  transform-origin: left top;
  box-shadow: 2px 1px 6px 1px red;
}
<div></div>
like image 165
Vitorino fernandes Avatar answered Sep 25 '22 13:09

Vitorino fernandes


Wrap it inside a parent div and give the parent border

http://jsfiddle.net/o6y997ds/

<div class="parent"><div class="div"></div></div>
.parent{
        border-radius:10px 0px 0px 0px;  
        overflow:hidden; 
       }
like image 31
Naeem Shaikh Avatar answered Sep 23 '22 13:09

Naeem Shaikh