I'm looking to create this overlapping circles shape in CSS:
Basically, just stacked circles. I've looked around, and all solutions I see include using multiple div elements for this effect. However, can't this be done with a single div, using CSS3? I looked at how it could be easily done, and figured that, if all colours are the same, you'd have a pill shape like this:
#circles {
background-color: red;
width: 130px;
height: 100px;
border-radius: 50px;
}
<div id="circles"></div>
And then simply draw a couple of quarter moons in it, and you're done. However, I can't figure out how to draw these moon shapes in my capsule shaped div.
Or, if you're feeling crazy, you could make an svg and use it inline as a background image:
With CSS box-shadows
You can use multiple box-shadows with several colours on a rounded div. They need to be seperated by a comma:
output :
Browser support for box-shadows is IE9+ (for more info see canIuse)
You can also make the overlapping circles shape responsive according to the width of the viewport with vw units : DEMO
Browser support for vw units is IE9+ (for more info see canIuse)
With SVG
Another approach would be to use an inline svg with the
<circle>
element.This is responsive according to the size of the parent and browser support goes back to IE9 like box-shadows :
I also expanded on the SVG version to make an animated "worm" with more overlapping circles. You can see it in this pen : animated worm
And it looks like this :
It is possible to use CSS3 multiple background images and radial gradients together: