样式组件不覆盖背景
下面,Button
的所有属性都将覆盖 PillButton
的属性除了背景。我尝试过 background-color
得到了相同的结果。只有将 !important
添加到 background
才有效。
const { white, darkGrey } = theme.colors;
export const PillButton = styled.button`
align-items: center;
background: ${p => (p.selected ? white : darkGrey)};
border-radius: 25px;
border: none;
color: ${p => (p.selected ? darkGrey : white)};
cursor: pointer;
display: flex;
justify-content: center;
padding: 8px 16px;
white-space: nowrap;
:hover {
background: ${white};
color: ${darkGrey};
}
`;
const Button = styled(PillButton)`
text-transform: uppercase;
font-weight: 700;
font-size: 13px;
background: ${p =>
p.selected ? theme.colors.draftedBlue : theme.colors.midGrey};
font-family: "Roboto Condensed", sans-serif;
`;
Why isn't background working?
In the following, all the properties of Button
are overriding the properties of PillButton
except background. I've tried background-color
with the same result. Only adding !important
to background
works.
const { white, darkGrey } = theme.colors;
export const PillButton = styled.button`
align-items: center;
background: ${p => (p.selected ? white : darkGrey)};
border-radius: 25px;
border: none;
color: ${p => (p.selected ? darkGrey : white)};
cursor: pointer;
display: flex;
justify-content: center;
padding: 8px 16px;
white-space: nowrap;
:hover {
background: ${white};
color: ${darkGrey};
}
`;
const Button = styled(PillButton)`
text-transform: uppercase;
font-weight: 700;
font-size: 13px;
background: ${p =>
p.selected ? theme.colors.draftedBlue : theme.colors.midGrey};
font-family: "Roboto Condensed", sans-serif;
`;
Why isn't background working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论