gpt4 book ai didi

css - 如何通过子项更改父级样式 :hover action in LESS

转载 作者:技术小花猫 更新时间:2023-10-29 11:15:18 32 4
gpt4 key购买 nike

我有这个 LESS 设置:

.wrapper {
.parent {
height: 100px;

.children {
//some style;

&:hover {

.parent & {
height: 150px;
}
}
}
}
}

我需要通过将鼠标悬停在其中的某个子元素上来更改父元素的一些高度。这段代码不起作用,那么有没有可能做到这一点?非常感谢您的帮助。

最佳答案

:hover 添加到 .parent 而不是 .children div 将实现结果,http://codepen.io/duncanbeattie/pen/xvDdu

.wrapper {
.parent {
pointer-events:none;
height: 100px;
background:#000;
.children {
//some style;
height:20px;
background:#f00;
pointer-events:all;
}
&:hover {
height:150px;
}
}
}

关于css - 如何通过子项更改父级样式 :hover action in LESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16672455/

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