Day # 25: Pour more wine!
When I was working on a previous project that involved the styling of a slider, I thought maybe it’d be fun to work on a project in which the slider would vary the amount of the filing with a cup or a glass.
For today’s project, I decided to work on a glass that would have a slider to decrease or increase the amount of wine inside of it. The key here was to select the element in Javascript, and then modify the background-position property to fill the glass:
martini.style.backgroundPosition = "0 "+"-"+slider.value +"px"
slider.oninput = function() {
martini.style.backgroundPosition = "0 "+"-"+slider.value +"px"
}
Comments
Post a Comment