我正在努力将悬停效果应用于该父 div 内的父级和所有子级。我正在尝试关注但它不起作用..
function changeBackground(e) {
e.target.style.backgroundColor = "#ff6f00";
e.target.style.color = "#ffffff";
}
function resetBackground(e){
e.target.style.backgroundColor = "#ffffff";
e.target.style.color = "#616161";
}
class InfoBlogs extends React.Component{
render(){
return(
<div id = "parent" style = { styles.parentCard } onMouseOver={changeBackground}
onMouseLeave={resetBackground}>
<div style={ styles.child1Card } id = "head">
<div style = { styles.c11 }>
<h2 style={styles.cardTitle}>Challenge</h2>
</div>
<div style = { styles.c12 } id = "footer">
<IoIosLogIn style={ styles.iconStyle } />
</div>
</div>
<div style={ styles.child2Card }>
<p style={ styles.cardContent }> The sky is pink.</p>
</div>
</div>
);
}
}
当鼠标悬停在孩子上时,它会影响孩子的特定部分而不是整个父 div。谁能告诉我如何使用 reactjs 实现这一目标