简体   繁体   English

如何在 CSS 中为复杂形状添加圆角

[英]How do I add rounded corners to complex shapes in CSS

How can I make the corners of a complex shape rounded in CSS?如何在 CSS 中使复杂形状的角变圆? Similar to how VSCode rounds the corners of selected code.类似于 VSCode 如何对选定代码的角进行圆角处理。 I know how to make a regular rectangle rounded in CSS but how do I join the rounded corners if the rectangles touch or intersect?我知道如何在 CSS 中制作圆形的常规矩形,但是如果矩形接触或相交,我该如何连接圆角? If necessary, using JavaScript for this is also ok (just not canvas or something like that).如有必要,为此使用 JavaScript 也可以(只是不是画布或类似的东西)。 Here's an example of how VSCode does it:这是 VSCode 如何做到的一个例子:

示例截图

I've researched this and have only found a lot of solutions for rectangles but nothing about non-convex or even non-rectangular shapes.我对此进行了研究,并且只找到了很多矩形的解决方案,但对非凸形甚至非矩形形状一无所知。

as pointed out in a comment, How to apply rounded borders to highlight/selection answers the problem specifically for highlighted text.正如评论中所指出的, How to apply rounded border to highlight/selection专门针对突出显示的文本回答了问题。 For other complex shapes (like literally, any other shape) I'll just have to settle on using canvas or SVG although that wasn't really the goal.对于其他复杂的形状(如字面意思,任何其他形状),我只需要决定使用 canvas 或 SVG,尽管这并不是真正的目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM