I have a fully functional spinning loading indicator in pure CSS, works great with a non-white background (the page background is gray in the example below). The circles are apparently white by default so if I set the page background to white, nothing shows. How would I modify the CSS so that it works with a white background too? For the sake of an example let’s say the circles should be green.
<html>
<head>
<style>
.loading {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.loading div {
position: absolute;
border: 4px solid #fff;
opacity: 1;
border-radius: 50%;
animation: loading 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.loading div:nth-child(2) {
animation-delay: -0.5s;
}
@keyframes loading {
0% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
}
4.9% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 0;
}
5% {
top: 36px;
left: 36px;
width: 0;
height: 0;
opacity: 1;
}
100% {
top: 0px;
left: 0px;
width: 72px;
height: 72px;
opacity: 0;
}
}
</style>
</head>
<body style="background-color: gray;">
<p>beginning</p>
<div class="loading">
<div></div>
<div></div>
</div>
<p>end</p>
</body>
</html>
2
Answers
From @jme11: just changing the border color like this did the trick:
If you add a blend mode, then your WHITE circles will be visible on any background: