Reputation: 55
So, I have the css below on my page. I want my visitors to be able to change the color of that image by typing in a #colorcode in a text field. Is something like this even possible?
.button{
background-image:url(../pattern/_img/button.png);
background-repeat:no-repeat;
display:block;
width:53px;
height:53px;
float:left;
margin:16px;
-ms-touch-action: none;
}
Upvotes: 0
Views: 743
Reputation: 221
What you can do is to change your image. Take a PNG image with white outside and empty (but let your gradient) inside like this for you:
Then set a div behind the image. It's the background-color of that div which will change. In your js just set:
element.style.backgroundColor = document.getElementById('color').value;
This not use canvas but this is working with few code.
Sorry for the english and hope it will help you!
Ah, and the image above is here.
Upvotes: 4