1

I have a simple CSS file with the following content:

button {
  border-radius: 4px;
  border-style: none;
  padding: 8px 16px 8px 16px;
  cursor: pointer;
  background-color: #2a5788;
  color: white;
}

button :hover {
  color: white;
  background-color: black;
}

In the HTML file, I have a simple button. The button style is being applied as expected, but, the :hover property is simply ignored. But, if I put something inside the button, like an icon, when the mouse is hover the icon, the icon background turns black.

<button>
    <i class="fas fa-play"></i>
    Adicionar Rastreio
</button>

Blue button with text "Adicionar Rastreio" and a play icon. The mouse is hover the play icon and the icon background is black, but the button background is blue.

I'm new to CSS, so I could be missing something.

How do I solve this problem?

dota2pro
  • 7,220
  • 7
  • 44
  • 79
Hugo Sartori
  • 560
  • 6
  • 21

1 Answers1

3

Remove the space button :hover {

Read More

button {
  border-radius: 4px;
  border-style: none;
  padding: 8px 16px 8px 16px;
  cursor: pointer;
  background-color: #2a5788;
  color: white;
}

button:hover {
  color: white;
  background-color: black;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>


<button>
    <i class="fas fa-play"></i>
    Adicionar Rastreio
</button>
dota2pro
  • 7,220
  • 7
  • 44
  • 79