如何在 React Native 中创建伪元素

oct*_*ian 5 css react-native

在 React Native 中,我有一个带有位置的框absolute,我在它后面放置另一个框。我知道如何在 CSS 中执行此操作的唯一方法是使用伪元素,如下所示

CSS:

#parent {
  width: 500px;
  height: 500px;
  background-color: white;
  border: 2px solid blue;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#parent::before {
  content: '';
  width: 60%;                           
  height: 60%;                         
}

#div1 {
  background: green;
  width: 30%;
  height: 30%;
  position: absolute;
  left: 50%;                            
  top: 50%;                             
  transform: translate(-50%,-50%);      
}

#div2 {
  background: red;
  width: 30%;
  height: 30%;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<div id="parent">
  <div id="div1"></div>
  <div id="div2"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

那么我怎样才能在 React Native 中做同样的事情呢?我可以有一个伪元素吗?