I want to make the circled outline half filled here is a picture and some code.
<body>
<div id="ui">
<div class="status">
<div class="health">
<i class="fa fa-solid fa-heart"></i>
</div>
<div class="armor">
<i class="fa fa-solid fa-shield-halved"></i>
</div>
<div class="hunger">
<i class="fa fa-solid fa-drumstick-bite"></i>
</div>
<div class="thirst">
<i class="fa fa-solid fa-wine-bottle"></i>
</div>
</div>
</div>
</body>
.thirst, .armor, .health, .hunger {
display: flex;
justify-content: center;
align-items: center;
outline-style: solid;
outline-offset: -3.5px;
outline-width: 3.5px;
border-radius: 100%;
font-size: 14px;
margin-top: 10%;
color: rgb(0, 0, 0);
height: 40px; width: 40px;
box-shadow: 0px 0px 2px rgb(0, 0, 0);
text-shadow: 0px 0px 1px rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.5);
}
The photo of the circle right now:
Was trying to use linear gradient but couldn’t get it to work.
2
Answers
You need to use radial-gradient when dealing with circular gradients. Change the percentages to change the thickness of the line.
Here’s how I would end up doing this. I don’t think using "outline" is a great way to do this. Rather, use a
background-image
with aradial-gradient
to cover the background, then aconic-gradient
with values in percent to show the health. In my example I’m using CSS vars to set the values. I have a few examples in the markup of how to modify them. I added a bit of color to show how that might be done flexibly.It looks like this for me: