gpt4 book ai didi

reactjs - 样式组件 : How to target direct children?

转载 作者:行者123 更新时间:2023-12-04 16:28:07 24 4
gpt4 key购买 nike

我在文档中看到 & 选择器用于嵌套定位。但以下不起作用。在这里使用的正确语法是什么?

const InlineContainer = styled.div`
display: flex;

& > * {
margin-right: "40px";
}
`;

最佳答案

作为 CSS 值,字符串 "40px"在值 40px 处无效做。

const FlexBox = styled.div`
margin: 20px;
padding: 20px;
border: 1px solid palevioletred;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;

> * {
background-color: yellow;
padding: 20px;
}

> div {
border: 2px solid black;
}
`;

Edit Q-58690167-DirectChildExample

关于reactjs - 样式组件 : How to target direct children?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58690167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com