I'm trying to make a transition effect with background-color when hovering a div element. The color change works exactly as I expected (from red to black in 3 seconds). However, the element receives an undesirable fade-in effect whenever the browser opens or refresh my HTML page.
In order to check if this would happen to other HTML elements, I also tried to apply the same CSS transition to a text element. As a result, the text fades from black to red when the page opens. This is also undesirable since the text should start red and turn to black just when I hover it.
Here is my code:
body {
margin: 0;
}
.exemplo1 {
margin: auto;
margin-top: 100px;
width: 200px;
height: 200px;
background-color: #F00;
transition: background-color 3s linear;
-moz-transition: background-color 3s linear;
-o-transition: background-color 3s linear;
-webkit-transition: background-color 3s linear;
}
.exemplo1:hover {
background-color: #000;
}
p {
color: #F00;
font-size: 25px;
font-weight: bold;
transition: color 3s linear;
-moz-transition: color 3s linear;
-o-transition: color 3s linear;
-webkit-transition: color 3s linear;
}
p:hover {
color: #000;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Página de Teste</title>
<link rel="stylesheet" href="transicoes.css" />
</head>
<body>
<div class="exemplo1"></div>
<p>Ola mundo!</p>
</body>
</html>
And here is how the file opens at Google Chrome: https://youtu.be/o6LdihbZIBU
This is happening at Google Chrome, Opera and Microsoft Edge, but not at Firefox. I'm using VS Code as my text editor.
Would you guys have any idea of why this is happening?