.container
svg(viewBox="10 10 200 100")
path(d='M20,20 C20,100 200,0 200,100')
.block
input(type='range', min='0', max='100', step='1')
h1 offset-distance: 50%;
View Compiled
* {
box-sizing: border-box;
}
body {
display: -webkit-box;
display: flex;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: center;
justify-content: center;
min-height: 100vh;
background: #ddd;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
flex-direction: column;
color: #222;
}
@media (prefers-color-scheme: dark) {
body {
background: #222;
color: #ddd;
}
}
:root {
--line: #0fa;
}
svg {
height: 150px;
width: 200px;
}
path {
fill: none;
stroke: var(--line);
stroke-width: 5px;
}
.container {
position: relative;
}
.block {
offset-path: path('M20,20 C20,100 200,0 200,100');
width: 40px;
height: 40px;
border-radius: 50%;
background: rgba(0,64,255,0.5);
position: absolute;
top: 50%;
left: 50%;
margin-left: -110px;
margin-top: -62px;
border: 4px solid var(--line);
offset-distance: calc(var(--distance, 50) * 1%);
}
const INPUT = document.querySelector('input')
const BLOCK = document.querySelector('.block')
const H = document.querySelector('h1')
const update = e => {
BLOCK.style.setProperty('--distance', e.target.value)
H.innerHTML = `offset-distance: ${e.target.value}%;`
}
INPUT.addEventListener('input', update)
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.