css 三角形边框

css border with triangle shape

有什么方法可以用 css 在左边创建边框吗?

完整 css 可以工作,但您应该使用 .png 作为 background-image 或者您可以使用 .svg,因为您可以动画化 and/or 每个 point 更改或pixel. You might be able to use just CSS但这需要大量的调平和定位以及大量的绝对和相对定位层。因为Css只会改变元素的full宽度,而且只能用来改变元素的宽度。你可以做的是使用 .svg,你可以映射每个可以动画的像素。

使用零维度 :before 加粗的部分边框

通过调整:before伪元素上border-width的top/bottom和left/right值,可以有效改变三角形的倾斜度。然后可以更改 left 位置以正确对齐伪元素。

a {
  display: inline-block;
  position: relative;
  margin-left: 14px; /* Should counter `left` value of `a:before` */
  padding: .5em 1em;
  color: #fff;
  font: bold 1em/1 sans-serif;
  text-decoration: none;
  text-transform: uppercase;
  border-radius: 0 0 10px 10px;
  background: #75bf41;
}
a:before {
  content: '0B'; /* zero-width non-breaking space */
  display: block;
  position: absolute;
  top: 0;
  left: -14px; /* Adjust to align */
  width: 0;
  height: 0;
  border-width: 14px 8px; /* Adjust top/bottom and left/right to skew */
  border-style: solid;
  border-color: #75bf41 #75bf41 transparent transparent; /* Triangle orientation. */
}
<a href="#">Español</a>

这里有一个使用 CSS 的方法;你只是将平行四边形和矩形分层:

.espanolIcon
{
    width: 300px;
    height: 100px;
    padding-left: 30px;
}
.rectangle {
    position: absolute;
    top: 0px;
    left: 200px;
    width: 200px;
    height: 100px;
    background-color: green; 
    border-radius: 0px 0px 30px 40px;
}

.arrow-left {
    position: absolute;
    top: 0px;
    width: 300px;
    height: 100px;
    background-color: green;
    -webkit-transform: skew(22deg); 
    transform: skew(22deg); 
    border-radius: 0px 0px 30px 40px;
    
}

h1 {
    color: white;
}
<div class="espanolIcon">
    <div class="rectangle"><h1>Espanol</h1></div>
    <div class="arrow-left"></div>
    
    
</div>

我使用边框和伪元素完成了它。

<ul>
  <li class="lang-item lang-item-6 lang-item-es">
    ::before
    <a>Español</a>
  </li>
</ul>

ul {
    position:relative;
}

.lang-item {
   text-align: right;
   position: relative;
}

.lang-item a {
   background: #76c53f;
   padding: 15px;
   color: #fff;
   text-transform: uppercase;
   border-bottom-right-radius: 10px;
   border-bottom-left-radius: 14px;
 }

.lang-item::before {
    position: absolute;
    right: 101px;
    top: -15px;
    content: "";
    display: inline-block;
    border-top: 40px solid #76C541;
    border-left: 40px solid transparent;
}

jsfiddle