【发布时间】:2020-12-12 13:30:42
【问题描述】:
我正在尝试定位样式组件的 3 个子 divs,但我无法弄清楚我的语法有什么问题,并且样式组件文档似乎没有很好地涵盖这一点.我的代码是:
const HamburgerButton = styled.div`
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
min-height: 60%;
min-width: 50px;
border-radius: 8px;
&:nth-child(1){
width: 32px;
min-height: 3px;
background-color: red;
}
&:nth-child(2){
width: 32px;
min-height: 3px;
background-color: red;
}
&:nth-child(3){
width: 32px;
min-height: 3px;
background-color: red;
}
`
const MobileNav = () => {
const [open, setOpen] = useState(false)
return (
<MobileNavContainer>
<Name>
<h1>Josh Bangle</h1>
</Name>
<HamburgerButton>
<span />
<span />
<span />
</HamburgerButton>
</MobileNavContainer>
);
}
nth-child(2) 选择器似乎出于某种原因设置了 HamburgerButton 组件本身的样式,所以我只能想象这是一个语法问题,尽管谷歌搜索对我没有任何帮助。
【问题讨论】:
标签: css reactjs sass styled-components