用CSS弯曲矩形的长度?

用CSS弯曲矩形的长度?,css,Css,可以用CSS制作这个形状吗?边界半径不能这样做,有没有其他方法可以“弯曲”矩形的侧面 我不认为有任何广泛的方法可以用纯css构建这样的形状 您可以尝试使用内嵌svg: background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><linearGradient id='gradient'><stop

可以用CSS制作这个形状吗?边界半径不能这样做,有没有其他方法可以“弯曲”矩形的侧面


我不认为有任何广泛的方法可以用纯css构建这样的形状

您可以尝试使用内嵌svg:

background-image: 
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><linearGradient id='gradient'><stop offset='10%' stop-color='%23F00'/><stop offset='90%' stop-color='%23fcc'/> </linearGradient><rect fill='url(%23gradient)' x='0' y='0' width='100%' height='100%'/></svg>");
编辑:我制作了一把小提琴:
您还可以尝试查看css属性
剪辑路径

这样做会使矩形具有弯曲的边缘:

div {
border: 2px solid;
border-radius: 25px;
}

与其他答案一样,使形状完美的最佳方法是使用SVG。然而,在css3和伪元素的帮助下,你可能会有紧密的形状

这一个远远不够好,因为我已经将作为一个快速示例,但随着时间的推移,您可能会得到更好的结果:

div {
  position: relative;
  width: 200px;
  height: 150px;
  margin: 20px 0;
  background: green;
  border-radius: 50% / 10%;
  color: white;
  text-align: center;
  text-indent: .1em;
}
div:before {
  content: '';
  position: absolute;
  top: 10%;
  bottom: 10%;
  right: -5%;
  left: -5%;
  background: inherit;
  border-radius: 5% / 50%;
}
div:after {
  content: '';
  position: absolute;
  bottom: 0px;
  right: -11px;
    width: 130px;
  height: 120px;
  background: green;
  border-radius: 20% / 150%;        
}

据我所知,除非您使用背景图像或将其拆分为多个div(对于每个圆形部分),否则您可以使用border radius执行很多操作-请参见此-您可以使用画布和JS吗?也许这可以帮助你,我没有投反对票,但你可能想重读这个问题。您的答案并没有真正解决这个问题,它只是一个例子,说明了如何使标签具有弯曲的边框。特别是其中有一个25像素的弯曲。如果你把一个长方形的东西放进去,比如一个按钮,那么这个按钮将有四条25像素的曲线。我不认为“弯曲”矩形的边,是吗它只是“弯曲”了一个角,而这不是问题的所在。是的,弯曲一条线就是弯曲;但是,不同于弯曲一条边和弯曲一个矩形的角(边!=角)。在任何情况下,你的答案都不会产生一个接近OP需要的形状。。。你有没有重读过这个问题?
div {
  position: relative;
  width: 200px;
  height: 150px;
  margin: 20px 0;
  background: green;
  border-radius: 50% / 10%;
  color: white;
  text-align: center;
  text-indent: .1em;
}
div:before {
  content: '';
  position: absolute;
  top: 10%;
  bottom: 10%;
  right: -5%;
  left: -5%;
  background: inherit;
  border-radius: 5% / 50%;
}
div:after {
  content: '';
  position: absolute;
  bottom: 0px;
  right: -11px;
    width: 130px;
  height: 120px;
  background: green;
  border-radius: 20% / 150%;        
}