【发布时间】:2021-07-13 02:59:42
【问题描述】:
我正在尝试编写我的自定义下拉组件,但我有一个问题,即使我将绝对位置设置为我的模态和高 z-index,在我的下拉下方的组件似乎在顶部。此行为在 Web 开发中通常不会发生,因为position: absolute 创建了新的层堆栈。如何解决?
const Container = styled(Flex)`
position: relative;
`
const Options = styled(Flex)`
background-color: ${colors.white};
position: absolute;
z-index: 999999;
transform: translateY(26px);
top: 0;
left: 4px;
right: 4px;
box-shadow: 0 -3px 6px rgba(0, 0, 0, 0.16);
border-bottom-left-radius: 26px;
border-bottom-right-radius: 26px;
`
const Option = styled(TouchableOpacity)`
display: flex;
justify-content: center;
flex-grow: 1;
height: 52px;
padding: 0 16px;
`
const Select = (props: Props) => {
const { items, value, ...rest } = props
return (
<Container direction="column">
<Input />
<Options direction="column">
<Option>
<Text>Opcja 1</Text>
</Option>
<Option>
<Text>Opcja 1</Text>
</Option>
</Options>
</Container>
)
}
export { Select }
【问题讨论】:
标签: css ios reactjs react-native z-index