我正在尝试实现类似图表的条形图。我有以下 html 元素
<rect x="35" y="-135" width="10" height="51" style="stroke: rgb(255, 255, 255); opacity: 0.8; fill: rgb(255, 122, 0);"></rect>
我想给 矩形的顶角一个圆角。这怎么可能?
我无法应用 border-radius 属性。
原文由 Dhanya 发布,翻译遵循 CC BY-SA 4.0 许可协议
3 回答901 阅读✓ 已解决
4 回答1.3k 阅读✓ 已解决
2 回答928 阅读✓ 已解决
2 回答1.5k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
2 回答899 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
您也可以使用
clipPath
。这有点像 hack,但可能更容易实施。假设如下:
rect
是width="10"
和height="51"
rx="5"
和ry="5"
一些注意事项:
所以
clipPath > rect > width
与你的rect
完全一样。而对于
clipPath > rect > height
,你必须考虑顶部的角半径,因此高度应该是rect.height
+desired-corner-radius
情况下 + –1。这样你就不会用
clipPath
矩形的底部。