gpt4 book ai didi

html - CSS-在悬停时同时更改子项和父项

转载 作者:太空宇宙 更新时间:2023-11-03 23:04:44 25 4
gpt4 key购买 nike

所以我有两个类:parentchildparent 类基本上是一个 Square,child 类包含 Square 中的文本。我正在努力改变parent 的背景色和 child 悬停在父级上时的文本颜色。这是我目前所拥有的,它只改变了 parent 的背景颜色:

.parent:hover {
background-color: #FFCC00;
}

我也试过了,但没用:

.panel-body:hover .child {
background-color: #FFCC00;
color: #FFFFFF;
}

编辑:因为没有任何解决方案有效。我正在添加 HTML 代码段。

<div class="parent">
<span class="arrow1"><i class="left-arrow" role="numerical"></i></span>
<div class="child ng-binding">
Child Text needing color change
</div>
<div class="child-2 ng-scope">
No change needed for this text
</div>
</div>

最佳答案

我相信你想要像这样结合你的两种尝试:

.parent:hover {
background-color: #FFCC00;
}
.parent:hover .child {
color: #FFFFFF;
}
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js">
</script>
<div class="parent">
<span class="arrow1"><i class="left-arrow" role="numerical"></i></span>
<div class="child ng-binding">
Child Text needing color change
</div>
<div class="child-2 ng-scope">
No change needed for this text
</div>
</div>

关于html - CSS-在悬停时同时更改子项和父项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35140612/

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