I would like to ask how should I apply different colour glow to an image border when a user hover over? like say that in this JSFiddle file, I have a green thumb and a red thumb. I want each image border to glow according to the colour of the image, or any colour that I specify. How should I achieve that?
PS** For example purposes the image are converted to base64 in the JSFiddle.
This is how I do in my CSS
img{
width: 16px;
cursor: pointer;
padding: 10px;
}
img:hover{
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
Thank You
As written in the comment, there is no way for HTML/CSS to determine the main color of the image displayed. If you know the predominant color of each image, give them class names accordingly and write the related CSS.
See demo for a simple version.
img.green:hover{
border-color: #66afe9;
box-shadow: 0 0 8px rgba(0,255,0, 0.6);
}
img.red:hover{
border-color: #66afe9;
box-shadow: 0 0 8px rgba(255,0,0, 0.6);
}
If I understand your question then here is an example DEMO
img{
width: 48px;
cursor: pointer;
/*padding: 10px;*/
/* border:1px solid #fff;*/
margin-right: 20px;
}
img:hover{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
-moz-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
}
img:last-of-type:hover{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
-moz-box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With