Juan Luis
Juan Luis

Reputation: 13

Hover button not working

I have a problem with the hover of this button, I can not make .icon-search turn white when I pass the cursor in the #search-button.

    .icon-search {
        fill: #868585;
        width: 20px
    }

    .icon-search {
        margin: 0 20px;
    }

    #search-button {
        border-radius: 0px 2px 2px 0px;
        border-color: #303030 !important;
        background-color: #343434;
        border: 2px solid;
        cursor: pointer;
        outline: none;
    }

    #search-button,
    .icon-star:hover {
        fill: white;
        color: white
    }
<!DOCTYPE html>

<html>
<head>
    <title>
    </title>
</head>

<body>
    <button id="search-button" type="submit"><svg aria-hidden="true" class=
    "icon icon-search" height="28" viewbox="0 0 26 28" width="26" xmlns=
    "http://www.w3.org/2000/svg">
    <path d=
    "M18 13c0-3.859-3.141-7-7-7s-7 3.141-7 7 3.141 7 7 7 7-3.141 7-7zm8 13c0 1.094-.906 2-2 2a1.96 1.96 0 0 1-1.406-.594l-5.359-5.344a10.971 10.971 0 0 1-6.234 1.937c-6.078 0-11-4.922-11-11s4.922-11 11-11 11 4.922 11 11c0 2.219-.672 4.406-1.937 6.234l5.359 5.359c.359.359.578.875.578 1.406z">

    </path></svg></button>
</body>
</html>

strong text

I want the cursor to go through the .icon-search, #search-button turn white.

Upvotes: 1

Views: 198

Answers (1)

Jakub Muda
Jakub Muda

Reputation: 6734

I changed your css a little and it works. There is a comma in your code right here: #search-button,.icon-star:hover and :hover should be added to #search-button. Plus, in your CSS instead of .icon-search you added .icon-star. This prevents the icon to change color on button hover.

Notice that I minified the code and I left what is required for the problem.

#search-button {background-color:#343434}

#search-button .icon-search {
        fill: #868585;
        width: 20px;
        margin: 0 20px;
}
#search-button:hover .icon-search {
        fill: white;
}
<button id="search-button" type="submit">
    <svg aria-hidden="true" class="icon icon-search" height="28" viewbox="0 0 26 28" width="26">
        <path d="M18 13c0-3.859-3.141-7-7-7s-7 3.141-7 7 3.141 7 7 7 7-3.141 7-7zm8 13c0 1.094-.906 2-2 2a1.96 1.96 0 0 1-1.406-.594l-5.359-5.344a10.971 10.971 0 0 1-6.234 1.937c-6.078 0-11-4.922-11-11s4.922-11 11-11 11 4.922 11 11c0 2.219-.672 4.406-1.937 6.234l5.359 5.359c.359.359.578.875.578 1.406z"></path>
    </svg>
</button>

Upvotes: 1

Related Questions