React native - 伪元素等价物

时间:2018-02-07 21:01:02

标签: reactjs react-native

我想在顶部创建一个带有条纹的按钮,它看起来像是在按钮后面(图片如下)。

image description

我已经使用 :: after 伪类在纯CSS中解决了这个问题。但我不确定如何在React中做到这一点。任何建议或帮助都是适用的。

1 个答案:

答案 0 :(得分:0)

有一种使用迷人的div的方法。

const IconDiamond = glamorous.div(
  {
    width: 0,
    height: 0,
    border: '50px solid transparent',
    borderBottomColor: 'red',
    position: 'relative',
    top: '-50px',
    '&::after': {
      content: `''`,
      position: 'absolute',
      left: '-50px',
      top: '50px',
      width: '0',
      height: '0',
      border: '50px solid transparent',
      borderTopColor: 'red',
    }
  },
)

请注意:

请检查此以获取更多信息:https://github.com/paypal/glamorous/issues/223

要详细了解迷人的div https://glamorous.rocks/basics