【问题标题】:How to show background in styled-components?如何在样式组件中显示背景?
【发布时间】:2018-10-20 11:06:03
【问题描述】:

在我的 react-app 中,我看不到背景/边框样式。我做错了什么?

是这样的:

 <Flex>
        <Box
          bg="blue"
          css={{
            borderRadius: "4px"
          }}
        />
 </Flex>

codesandbox

【问题讨论】:

    标签: css styled-components


    【解决方案1】:

    盒子里没有内容。 添加任何内容时,您将看到边框半径和背景颜色。 如果你像下面这样改变,那么你会看到背景。

    <Flex>
        <Box
           bg="blue"
           css={{
             borderRadius: "4px"
           }}
        >
           lorem texts
        </Box>
    </Flex>
    

    你可以指定

    宽度={1}

    使盒子有全宽。

    【讨论】:

      猜你喜欢
      • 2020-12-23
      • 1970-01-01
      • 1970-01-01
      • 2017-12-25
      • 1970-01-01
      • 2020-09-28
      • 2020-03-20
      • 2011-06-09
      • 2022-01-02
      相关资源
      最近更新 更多