gpt4 book ai didi

css - 悬停时向多个元素添加样式 - scss

转载 作者:太空宇宙 更新时间:2023-11-04 02:08:16 24 4
gpt4 key购买 nike

我目前有这段代码,当将鼠标悬停在页脚单元格上时,它会将页脚标题和副标题变为白色,并且有效:

.footer-cell {
position: relative;
display: table;
height: 160px;

&:hover .footer-title { // footer-title line
color: white;
}

&:hover .footer-subtitle { // footer-subtitle line
color: white;
}
}

有什么方法可以组合页脚标题行和页脚副标题行,这样我就没有重复的代码了吗?我试过这个但它不起作用:

.footer-cell {
position: relative;
display: table;
height: 160px;

&:hover .footer-title, .footer-subtitle {
color: white;
}
}

最佳答案

只需将选择器包装在 :hover 类中:

.footer-cell {
position: relative;
display: table;
height: 160px;

&:hover{
.footer-title, .footer-subtitle {
color: white;
}
}
}

Compiles to this

关于css - 悬停时向多个元素添加样式 - scss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40265760/

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