如何在react-select下拉列表中更改z Index

问题描述 投票:0回答:1

我正在使用react-select库来创建自动完成下拉列表。我已经使用了2下拉并行,如果第二个有一些数据我打开第一个然后zIndex问题来了。见imageenter image description here

reactjs react-select
1个回答
2
投票

尝试这种设置z索引的hacky方式,让我知道它是否有效:)

<Select
  styles={{
    // Fixes the overlapping problem of the component
    menu: provided => ({ ...provided, zIndex: 9999 })
  }}
  value={selectedOption}
  onChange={evt => onSelectChange(evt, index)}
  options={options}
/>
© www.soinside.com 2019 - 2024. All rights reserved.