In Vue, I'm trying to use style binding for the CSS "top" property of an HTML image element:
<img src="../assets/myimg.png" id="myimg" v-bind:style="[!ended ? 'top:20%' : 'top:80%']">
Here's the CSS for the image:
#myimg{
position: absolute;
width: 100px;
height: 10px;
left: 10%;
}
"ended" is just a prop that this component receives from its parent. If it's false, the "top" property of the image should be 20%, otherwise, it should be 80%.
Unfortunately, the image stays at the same position regardless of whether "ended" is true or false. How can I resolve this?