Currently tackling a frustrating bug while working on a component. The issue arises when clicking on a div that opens a menu, contained within a React component which is nested inside another.
Below is the CSS styling:
const FilterBox = styled("div")`
position: relative;
display: flex;
background-color: ${colours.silver};
border: 1px solid ${colours.silver};
border-radius: 4px;
padding: 4px;
height: 40px;
width: 40px;
align-items: center;
svg {
position: absolute;
vertical-align: middle;
display: inline-block;
margin-left: 4px;
text-align: center;
}
`;
const FilterMenu = styled("div")`
display: flex;
margin-top: 10px;
top: 13%;
right: 13vw;
background: #ffffff;
box-sizing: border-box;
-webkit-appearance: none;
box-shadow: 0px 2px 0px #dddee3;
border-radius: 4px;
display: ${(props) => (props.visible ? "block" : "none")};
label {
display: block;
width: 10vw;
margin: 10px;
padding-left: 10px;
}
span {
font-family: Roboto;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 24px;
display: flex;
align-items: center;
color: ${colours.night};
input {
margin-right: 8px;
width: 16px;
height: 16px;
border: 1px solid #0f7070;
box-sizing: border-box;
border-radius: 2px;
-webkit-appearance: none;
-moz-appearance: none;
:checked {
background-color: ${colours.green};
:after {
content: "\2714";
font-size: 14px;
position: absolute;
top: 0px;
left: 3px;
color: white;
z-index: 9999;
}
}
}
}
`;
Illustrative examples can be viewed at:
https://i.sstatic.net/gfN0J.png
https://i.sstatic.net/JOPy0.png
The menu appears, but the layout seems off and it doesn't appear to be responsive as intended. Where could I possibly be going wrong?
https://codesandbox.io/s/affectionate-platform-zjg8m?file=/src/App.js