I added justify-content: space-evenly
to a div in my React app, but I see no change. I have applied, display: flex
, align-items: flex-end
, and they all work as expected. I also tried flex-direction
to check that was working, and it did. I don't understand why justify-content
isn't working? I Have tried other values of justify-content
such as space-around
, space-between
and center
, but I had the same result, justify-content
doesn't seem to work at all. Below is my code for the component and the parent styles the component inherits...
---- Component ----
// Libraries
import styled from "styled-components";
import { useSelector, useDispatch } from "react-redux";
// Components and icons
import { StyledTop } from "../Components/styles";
import {
RecentlyPlayedIcon,
SettingsIcon,
QuitIcon,
} from "../Components/icons";
const RightBarButtons = () => {
// Grab needed state and set vars
const theme = useSelector((state) => state.theme);
const rightBarState = useSelector((state) => state.rightBarSelection);
const dispatch = useDispatch();
// Handlers
const buttonHandler = (buttonName) => {
if (buttonName !== rightBarState) {
dispatch({
type: `SET_RIGHT_BAR_${buttonName.toUpperCase()}`,
});
}
};
return (
<StyledTopButtons>
<button>
<QuitIcon theme={theme} />
</button>
<button
onClick={() => {
buttonHandler("settings");
}}
style={{
borderLeft: `4px solid ${
theme === "light" ? "rgba(0,0,0,.05)" : "rgba(255, 255, 255, 0.125)"
} `,
borderRight: `4px solid ${
theme === "light" ? "rgba(0,0,0,.05)" : "rgba(255, 255, 255, 0.125)"
} `,
}}
>
<SettingsIcon rightBarState={rightBarState} theme={theme} />
</button>
<button
onClick={() => {
buttonHandler("recently_played");
}}
>
<RecentlyPlayedIcon rightBarState={rightBarState} theme={theme} />
</button>
</StyledTopButtons>
);
};
const StyledTopButtons = styled(StyledTop)`
margin: 3.9rem 4rem;
width: calc(100% - 8rem);
display: flex;
align-items: flex-end;
justify-content: space-evenly;
button {
transform: translateX(-2.6rem);
height: 2.2rem;
cursor: pointer;
svg {
height: 100%;
pointer-events: none;
}
}
`;
export default RightBarButtons;
---- StyledTop
component, that I am inheriting from ----
export const StyledTop = styled.div`
height: 2.8rem;
width: 100%;
h1 {
margin: 4rem;
font-size: 2.8rem;
font-weight: 600;
color: ${(props) => (props.theme === "light" ? "black" : "white")};
cursor: pointer;
}
span {
color: #3ca8c9;
}
`;
If someone could help me figure out why this isn't behaving as expected I'd really appreciate it. Thanks.