I have two problems, but the main one is that the hover I am doing on a button changes the color of the text but does not change the background color and I do not understand how to fix it.
The second problem is that I have had to put its own background and it does not look good, but if not directly I do not catch the background of the normal aside (I do not know if there is some way to fix this so that it uses the same background).
aside {
font-family: Anderson;
width: 15%;
background: rgb(106, 36, 108);
background: linear-gradient(357deg, rgba(106, 36, 108, 1) 5%, rgba(57, 26, 84, 1) 100%);
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: space-evenly;
background-image: url(../Imagenes/Logo.png);
background-size: 80%;
background-position: top;
background-position-y: 10px;
background-repeat: no-repeat;
position: absolute;
top: 0;
bottom: 0;
left: 0;
}
aside a {
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 26px;
}
aside a:hover {
background-color: #ddd;
color: black;
}
aside a.active {
color: white;
text-decoration: dotted;
background: rgb(106, 36, 108);
}
aside button {
font-family: Anderson;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 26px;
background: rgb(106, 36, 108);
background: linear-gradient(357deg, rgba(106, 36, 108, 1) 5%, rgba(57, 26, 84, 1) 100%);
border-style: none;
cursor: pointer;
}
aside button:hover {
color: black;
background-color: #ddd !important;
}
<aside>
<p></p>
<a class="active" href="#"><i class="fa fa-fw fa-home"></i> Home</a>
<a href="Formulario.html"><i class="fa fa-wpforms"></i> Account</a>
<button class="btn-toggle"><i class="fa fa-fw fa-home darkmode"></i> Light Mode</button>
<a href="#"><i class="fa fa-fw fa-home"></i> About us</a>
</aside>
2
Answers
The problem with your button is that you defined its normal state using background: and the hover state using background-color: — they do not match.
If you switch it to:
aside button:hover {background: #ddd}
it will fix the problem and you also will not need the !important.The "normal" style is this:
The hover style is this:
The
background
shorthand property lets you set a selection of differentbackground-something
properties at once.linear-gradient
s arebackground-image
s, andbackground-image
s are rendered over the top ofbackground-color
s.So your hover style is being applied, but you can’t see it because it is covered up by the gradient.
Change the hover style to:
This will set the
background-color
to#ddd
and thebackground-image
tonone
so you’ll be able to see thebackground-color
.