使用以下html,当我将鼠标悬停在子项上时,我获得了父项的绿色背景.我怎么能阻止这种情况发生?如果我在子元素之外盘旋,我确实想要绿色背景.
CSS3很好.
.parent {
padding: 100px;
width: 400px;
height: 400px;
}
.parent:hover {
background-color: green;
}
.child {
padding: 100px;
width: 200px;
height: 200px;
}
.child:hover {
background-color: blue;
}Run Code Online (Sandbox Code Playgroud)