Days Remaining Indicator
css + svg
by moob
HTML
<div>
<h1>
Days Remaining Indicator
</h1>
<p>
Sort of. Its a bit lame...
</p>
<div class="lozenge">
<svg viewBox="0 0 240 120">
<rect class="bg" x="10" y="10" width="220" height="100" rx="50" />
<rect class="fg" x="10" y="10" width="220" height="100" rx="50" />
</svg>
<span>42</span>
</div>
</div>
CSS
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100&display=swap');
html, body {margin:0;}
body {
display: grid;
height: 100vh;
place-items: center;
background: #eee;
font-family: 'Montserrat', sans-serif;
padding-inline:20px;
}
.lozenge {
display: flex;
place-items: center;
position:relative;
width:6em;
line-height:2em;
border-radius:2em;
overflow:hidden;
}
.lozenge span {
display: grid;
position:absolute;
inset:0;
margin:auto;
font-size:2rem;
place-items: center;
}
svg {
width: 100%;
height: 100%;
background: white;
}
.bg, .fg{
fill: none;
stroke-width: 20px;
stroke: #ddd;
}
.fg {
stroke-dasharray: 1000px;
stroke-dashoffset: -300px;
stroke: blue;
animation: progress-1 1s ease-out;
}
@keyframes progress-1 {
from {
stroke-dashoffset: 0;
}
to {
stroke-dashoffset: -300;
}
}