0

I was wondering if I could animate two objects at once, I mean if I hover on one of the object the other would response too? lets say I have a button with material icons in it, if I hover on the text, it changes color but the icon does not! please help me!

            .button {
    margin-left: 19%;
    display: inline-flex;
    height: 50px;
    padding: 0;
    background: black;
    border: none;
    border-radius: 90px;
    outline: none;
    overflow: hidden;
    font-size: 24px;
    font-weight: 500;
    cursor: pointer;
    transition-duration: 0.2s;
}

    .button__text,
    .button__icon{
        font-family: 'Helvetica', sans-serif, Arial;
        display: inline-flex;
        align-items: center;
        padding: 0 10px;
        color: #d7d7d7;
        height: 100%;
    }

.button:hover{
    color: darkblue;
}

.button:hover {
    background: #040f16;
    color: black;
}

.button__icon{
    font-size: 1.2em;
}

1 Answers1

0

If you check this, instead of the icon, I have used another span, and I am only changing the colour of text, not the icon (S text). This way you can achieve what you are looking for

.button {
        display: inline-flex;
        height: 50px;
        padding: 20px;
        border: none;
        outline: none;
        overflow: hidden;
        font-size: 24px;
        font-weight: 500;
        cursor: pointer;
        transition-duration: 0.2s;
      }

      .text,
      .icon {
        font-family: "Helvetica", sans-serif, Arial;
        display: inline-flex;
        align-items: center;
        padding: 10px;
        height: 100%;
      }

      .button:hover .text {
        color: blue;
      }
<button class='button'>
  <span class='icon'>S</span>
  <span class='text'>Text</span>
</button>
Abin Thaha
  • 4,493
  • 3
  • 13
  • 41