I have a button but when I hover over it the text doesn't want to change color (color change class---- .active:hover
). For some odd reason it doesn't want to change. Also, as you can see in my code, I want to change the text color to #fff
(white). I use the :hover
selector quite often, and I don't know what the problem is!
body {
font-family: "Exo 2", sans-serif;
margin: 0;
padding: 0;
justify-content: center;
height: 100vh;
align-items: center;
}
.active {
text-decoration: none;
color: #000;
position: relative;
padding: 8px 30px;
background: #fff;
text-transform: uppercase;
font-size: 15px;
box-sizing: border-box;
transition: 0.5s;
border: 2px solid #000;
}
.active:before {
content: '' ;
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: #000;
z-index: 1;
transform: scaleX(0);
transition: transform 0.5s;
transform-origin: left;
}
.active:hover {
color: #fff;
}
.active:hover:before {
transform: scaleX(1);
transition: transform 0.5s;
transform-origin: right;
}
.active:after {
content: '' ;
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 100%;
background: #000;
z-index: 1;
transform: scaleX(0);
transition: transform 0.5s;
transform-origin: right;
}
.active:hover:after {
transform: scaleX(1);
transition: transform 0.5s;
transform-origin: left;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<a class="active" href="#">Login</a>
</body>
</html>