I\'m trying to transition on hover with css over a thumbnail so that on hover, the background gradient fades in. The transition isn\'t working, but if I simply change it to
Based on the css code in your question, I have try code as follows and it works for me (run the code snippet), and please try by yourself :
#container div a {
display: inline-block;
margin-top: 10%;
padding: 1em 2em;
font-size: 2em;
color: #fff;
font-family: arial, sans-serif;
text-decoration: none;
border-radius: 0.3em;
position: relative;
background-color: #ccc;
background-image: linear-gradient(to top, #C0357E, #EE5840);
-webkit-backface-visibility: hidden;
z-index: 1;
}
#container div a:after {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 0.3em;
background-image: linear-gradient(to top, #6d8aa0, #343436);
transition: opacity 0.5s ease-out;
z-index: 2;
opacity: 0;
}
#container div a:hover:after {
opacity: 1;
}
#container div a span {
position: relative;
z-index: 3;
}
Based on the css code in your question, I have try code as follows and it works for me, and please try by yourself :
#container div a {
display: inline-block;
margin-top: 10%;
padding: 1em 2em;
font-size: 2em;
color: #fff;
font-family: arial, sans-serif;
text-decoration: none;
border-radius: 0.3em;
position: relative;
background-color: #ccc;
background-image: linear-gradient(to top, #C0357E, #EE5840);
-webkit-backface-visibility: hidden;
z-index: 1;
}
#container div a:after {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 0.3em;
background-image: linear-gradient(to top, #6d8aa0, #343436);
transition: opacity 0.5s ease-out;
z-index: 2;
opacity: 0;
}
#container div a:hover:after {
opacity: 1;
}
#container div a span {
position: relative;
z-index: 3;
}
Does it works for you? Change the color based on your need :)