简体   繁体   English

将鼠标悬停在不是子代的工具提示上时,保持父样式的悬停样式

[英]Keep hover style on parent when hovering over a tooltip that is NOT a descendant

I have a "parent" div that contains an element with a tooltip control. 我有一个“父” div,其中包含带有工具提示控件的元素。 The tooltip is not child element of the parent div and is attached directly to the body element. 工具提示不是父div的子元素,而是直接附加到body元素。 We have a style when hovering over the parent which is lost when hovering over the tooltip. 当鼠标悬停在父级上时,我们有一种样式,当鼠标悬停在工具提示上时,样式会丢失。 Is there a CSS-based solution for keeping the hover style on the parent while hovering over the tooltip that is not a descendant of the parent? 是否有一种基于CSS的解决方案,可以在将鼠标悬停在不是父代后代的工具提示上时,在父代上保持悬停样式?

Just change this: 只需更改此:

#parent:hover {
    /*show tooltip*/
}

To this: 对此:

#parent:hover, #tooltip:hover {
    /*show tooltip*/
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM