I'm building a simple react app, and in that I try to change the name of a div using the statement -
<div className={'changeTab ' + (page.login ? 'leftSide' : 'rightSide')} id="tab" ></div>
but the CSS part for it disappears when trying to do so. The rest of the page works fine so there's no linking problem to the CSS file. And when I try to use only the ID name instead of the class names, the styles work fine. Only when using the class names in the CSS the styles disappear and they don't even show on the developer tools when using inspect. The class names do appear in the class attribute in HTML part of the developer tools, but the CSS properties do not.
I use a simple useState Hook for the conditional statement -
const [page, setPage] = useState([{
login: true,
signUp: false
}])
Here's the CSS -
#tab .changeTab .leftSide{
position: absolute;
height: 100%;
width: 50%;
left: 0;
background: -webkit-linear-gradient(right,#4361ee,#4cc9f0);
transition: all 0.6s cubic-bezier(0, 1.17, 0, 0.69);
border-radius: 5px;
}
#tab .changeTab .rightSide{
position: absolute;
height: 100%;
width: 50%;
left: 0;
background: red;
margin-left: -50%;
transition: all 0.6s cubic-bezier(0, 1.17, 0, 0.69);
border-radius: 5px;
}
I'm new to react so any help would be very much appreciated