gpt4 book ai didi

html - 悬停按钮不起作用

转载 作者:行者123 更新时间:2023-11-28 14:59:40 24 4
gpt4 key购买 nike

我对这个按钮的悬停有问题,当我将光标移到#search-button 时,我无法使 .icon-search 变白。

    .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>

强文本

我希望光标通过.icon-search,#search-button 变白。

最佳答案

我稍微更改了您的 CSS,它可以正常工作。您的代码中有一个逗号:#search-button,.icon-star:hover:hover 应该添加到 #search-button。另外,在您的 CSS 而不是 .icon-search 中,您添加了 .icon-star。这可以防止图标在按钮悬停时改变颜色。

请注意,我缩小了代码并保留了问题所需的内容。

#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>

关于html - 悬停按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50458431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com