Changing Div Border during Hover
I have a simple div.
<div id="sample"></div>
I made my border transparent using the following code:
var sample_div = document.getElementById('sample');
sample_div.style.borderColor = 'transparent';
I want the div border to be blue when the mouse pointer is in hover mode. Below is the css code:
#sample:hover{
border: 1px solid blue;
border-color: blue;
}
My css code is not working. It does not change color on hover. It remains transparent. Why?
border:0 #sample , javascript.
#sample {
width: 50px;
height: 50px;
background-color: lightgrey;
border: 0;
}
#sample:hover{
border: 1px solid blue;
border-color: blue;
}<div id="sample"></div>border-color JavaScript, <div id="sample" style="border-color: transparent;"></div>.
specificity , -: hover. , border-width border-style :hover, border-color - (), JavaScript.
To make it work, either raise the specification of the rule above with css by adding !importantor aligning JavaScript and setting the initial CSS style so that specificity is no longer a problem.