css - 更改包裹在 :hover? anchor 中的 div 的背景

标签 css

我想更改 #pianist a:hover 上 div.button 的背景图片。这可以用 CSS 实现吗?

<a id="pianist">
    <div class="button"></div>
    <h2>PIANIST</h2>
</a>

最佳答案

您可以通过将其嵌套在 #pianist:hover 下来定位它,如下所示:

example

#pianist:hover .button {
    background-color: red; /* replace with desired background declaration */
}

关于css - 更改包裹在 :hover? anchor 中的 div 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19342106/

相关文章:

css - Gtk3 textview 文本颜色与字体

html - 堆叠 div 元素

javascript 浏览器问题在 FF 中有效,但在 IE 和 Chrome 中无效

html - Bootstrap 移动列表菜单更改

CSS 不透明度不过渡

javascript - 使我的视频标题响应

CSS - 选择特定元素之外的所有元素

html - 如何使内容在 CSS 网格布局中居中?

html - 输入按钮的光标将无法设置为指针

javascript - 部分没有响应 CSS