0
I’ve been creating some transition in some projects and I ended up noticing that the transition occurs when the page is loaded or updated. I have this example where the transition is to occur only when I pass the mouse over to div
, and it changes the color with a smoother transition, but the transition is applied also when the page is loaded.
div{
background-color: red;
width: 200px;
height: 200px;
transition: background-color 2s;
}
div:hover{
background-color: black;
}
<div></div>
It looks like an opacity effect and then returns to normal color. This occurs only with the Chrome and Opera, because I tested on Firefox, Edge, IE11 and the effect does not happen in the stackoverflow I don’t think you’ll notice, you’ll have to create an html file, but is there any way to stop it from happening? either in code or in the browser?
I can’t say for sure, but this seems like Chrome’s arbitrary behavior... take a look at this question and look at my answer as you solved it. If it works for you. https://answall.com/questions/383494/css-functionand-different-dentro-da-tag-ou-em-arquivo-separado-css including tb I indicate resetting the machine, because maybe it could be hardware and memory management or whatever. Worth testing... here I tested with your code today and I had no problems worked normal as expected, only activates the traffic in :Hover and not in refresh
– hugocsl
No, it worked should be normal of Chrome and it operates to happen that, but it affects the projects that we create, it shouldn’t occur that.
– Leandro Nascimento
I only noticed this after the last Chrome update. But currently it does not happen to me anymore, at the time I solved with the answer I gave in the question of the link I commented above
– hugocsl
It was supposed to be a yes upstairs I misspelled. I tested the code and the animation happens before the Hover, it was very similar to my problem and I tested here the problem was fixed but because it occurs is a bug even or not?
– Leandro Nascimento
Young man, I marked as duplicate because the other answer/question seems to solve the problem as I suspected. Unfortunately I can’t tell you why this is happening.It may be your machine’s individual problem, or it may be general (I don’t believe it is) or it is browser version problem, which I believe is most likely, although I can’t say.... I can only tell you how to fix it, but I can’t tell you why this is happening...
– hugocsl
There is more ok, the important thing is that you helped me and solved the problem thank hugocsi
– Leandro Nascimento