简体   繁体   English

透明重叠的圆圈,背景无边框

[英]Transparent overlapping circles without border in background

Is it possible to implement transparent overlapping svg circle elements without circles border in transparent area? 是否可以实现透明重叠的svg圆形元素,而在透明区域中没有圆形边框?

在此处输入图片说明

You can clip the bits you don't want to draw... 您可以剪辑不想绘制的位...

 <svg height="100" width="150"> <defs> <clipPath id="clip" clipPathUnits="objectBoundingBox"> <rect width="0.79" height="1.2" x="-0.1" y="-0.1"/> </clipPath> </defs> <rect width="100%" height="100%" fill="blue" opacity="0.2" /> <circle cx="80" cy="50" r="40" stroke="black" stroke-width="3" fill="none" /> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="none" clip-path="url(#clip)"/> </svg> 

Check this link to view information about position absolute css code. 检查此链接以查看有关位置绝对CSS代码的信息。 I think this is what you are looking for. 我认为这就是您想要的。 You might also want to view information about z-index. 您可能还想查看有关z-index的信息。 If you have any questions or want me to write some sample code for your problem let me know 如果您有任何疑问或希望我为您的问题写一些示例代码,请告诉我

 svg{ position: absolute; } #svg-1{ top: 80px; left: 20px; } #svg-2{ top: 80px; left: 60px; } 
 <svg id="svg-1" height="100" width="100"> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg> <svg id="svg-2" height="100" width="100"> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg> 

You can also use a <mask> . 您也可以使用<mask>

I've used the same elements as @RobertLongson's answer so you can compare the approaches. 我使用了与@RobertLongson的答案相同的元素,因此您可以比较这些方法。

 <svg height="100" width="150"> <defs> <mask id="mask"> <!-- white rectangle to keep the area outside the circle --> <rect width="100%" height="100%" fill="white"/> <!-- black circle creates a "hole" to hide the part inside --> <circle cx="50" cy="50" r="40" fill="black"/> </mask> </defs> <rect width="100%" height="100%" fill="blue" opacity="0.2" /> <circle cx="80" cy="50" r="40" stroke="black" stroke-width="3" fill="none" mask="url(#mask)"/> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="none"/> </svg> 

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

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