Currently, I am working on CSS within Reactjs. In my project, I have two sibling elements: a logo and a text placed beside it. My goal is to have the text turn black when I hover over the logo, but so far, I have been unsuccessful in achieving this effect.
I attempted to share a className between the elements, but this approach did not work as expected.
Below is a snippet from my file.js:
export default () => {
return (
<div className={style.logo_flex}>
<div>
<Link to="/">
<img className={style.logo} src={Logo} alt=""/>
</Link>
</div>
<Link to="/">
<p className={style.brandName}> Coding </p>
</Link>
</div>
)
}
Here is the portion of my file.css responsible for styling:
/* Logo */
a {
text-decoration: none;
color: grey;
}
a:active {
border: none;
}
a:visited {
color: grey;
}
.logo_flex {
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
}
.logo_flex:hover {
color: black;
}
.logo {
left: 7%;
top: 0.2em;
height: 2.2em;
}
p, div {
display: inline-block;
}
.brandName {
margin-left: 1.2em;
align-self: center;
}
.brandName:hover, .logo:hover {
color: black;
}