I am trying to create a very specific image using CSS (unless there is a better way to do it which I have yet to discover). I have created the image using Photoshop, but the resolution is not as high as I want it to be. Below is the code and the result. What I want to do, though, is combine all three of the CSS styles into one so that every time I want to show the image, I don’t have to draw each of the three circles. Any insight would be great, or a better idea to achieve the same thing.
#box {
display: block;
width: 1.5em;
height: 1.5em;
background-color: #74afad;
position: absolute;
border-radius: 100%;
z-index: -1;
margin-top: auto;
margin-bottom: auto;
vertical-align: middle;
}
#whiteCircle {
display: block;
width: 1.25em;
height: 1.25em;
background-color: white;
position: relative;
border-radius: 100%;
z-index: 0;
margin-top: 50%;
top: -.625em;
margin-left: 50%;
left: -.625em;
vertical-align: middle;
}
#orangeCircle {
display: block;
width: 1em;
height: 1em;
background-color: #ff7e00;
position: absolute;
border-radius: 100%;
z-index: 1;
margin-top: 50%;
margin-left: 50%;
top: -.5em;
left: -.5em;
vertical-align: middle;
}
<div id="box">
<div id="whiteCircle">
<div id="orangeCircle">
</div>
</div>
</div>
Thank you!
2
Answers
You can reduce everything to a single CSS class by using pseudo-elements instead of explicit
div
tags.Instead of using an id selector, use a class (
.box
instead of#box
) and then you cansafely reuse the class throughout your pages.
try using gradients