Triangle with one rounded corner

2019-01-26 09:18发布

I want to make only one rounded corner for a triangle but I'm unable to make it.
Here is my code:

.arrow-left {
  width: 0;
  height: 0;
  border-top: 80px solid transparent;
  border-bottom: 80px solid transparent;
  border-right: 80px solid blue;
}
<div class="arrow-left"></div>

I need the corner pointing left to be rounded as shown in this image :

Triangle with a rounded corner

4条回答
姐就是有狂的资本
2楼-- · 2019-01-26 09:49

to your code to add this

border-radius:10px
查看更多
一夜七次
3楼-- · 2019-01-26 09:51

I know this is a little hacky, but I don't think there is an easy way to do this with a single class.

All I've done is rotated a box 45 degrees with border-radius:10px and then contained it in another div with width set to the desired width of your arrow and overflow:hidden so that everything that spills over is invisible.

http://jsfiddle.net/9D3Zn/5/

.arrow-left {
position:absolute;
width:100px;
height:100px;
left:50px;
background:black;
-webkit-transform:rotate(45deg);
transform:rotate(45deg);
border-radius:10px;
}

.cover {
position:absolute;
height:100px;
width:40px;
overflow:hidden;
}
查看更多
Summer. ? 凉城
4楼-- · 2019-01-26 09:54

You can try this and modify according to your needs.

http://jsfiddle.net/K44mE/947/

<div id="player">

  <div id="outer"><div id="inner">&nbsp;</div></div>

</div>

#player {
 margin: 32px;
 position: relative;        
 width: 400px;
 height: 250px;
 background-color: #222;   
}


#inner{
 transform: rotate(45deg);
 -ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
 -o-transform: rotate(45deg);
 -moz-transform: rotate(45deg); 
 background-color:silver;
 width:100px;
 height:100px;
 top: 20px;
 left: -60px;
 position:relative;
 -moz-border-radius: 20px;
 border-radius: 20px;
}

#outer {
 position: absolute;
 top: 50px;
 left: 165px;
 width: 70px;
 height: 140px;    
 overflow: hidden;
}
查看更多
可以哭但决不认输i
5楼-- · 2019-01-26 10:08

You can make a responsive triangle with one rounded corner with at least 2 approaches :

With CSS:

With one divand a pseudo element and:

.arrow-left {  
  position: relative;
  width: 15%;
  padding-bottom:15%;
  border-radius: 10px;
  overflow: hidden;
  transform-origin:100% 0;
  transform: rotate(-45deg);
}
.arrow-left:after {
  content: "";
  position: absolute;
  top: 0; right:8px;
  width:100%; height:141%;
  transform-origin:inherit;
  transform: rotate(45deg);
  background:#000;
}
<div class="arrow-left"></div>

Note that you need to add the vendor prefixes to the transform and transform-origin properties (more info on canIuse)

With inline SVG:

This example uses one path element for the triangle with a bezier curve command for the rounded corner (Q0 5 0.8 4.2 in the d attribute):

svg{
  display:block;
  width:10%;
}
<svg viewbox="0 0 5 10">
  <path d="M5 0 V10 L0.8 5.8 Q0 5 0.8 4.2z" />
</svg>

查看更多
登录 后发表回答