css - 将 react-native-popup-menu MenuOptions 右对齐

标签 css react-native react-native-popup-menu

我一辈子都想不出如何让下拉菜单右对齐。我试过使用 flex-end 和 right: 0 等进行绝对定位。

我希望在主触发器黄色框的右侧、下方和紧靠右侧列出菜单选项。或者至少对接在粉红色框的右侧。我可以使用 marginTop 轻松更改高度位置。

enter image description here

const TermPlanSelector = ({ options, selected, onChangeCallback }) => (
<Menu style={{ borderColor: 'yellow', borderWidth: 1 }}>
    <MenuTrigger style={[formStyles.optionsSelectContainer]}>
        <Text style={[formStyles.optionsSelectorText, { borderColor: 'pink', borderWidth: 1 }]}>
            { getLabel(selected, options) }
        </Text>
        <SelectorDownIcon />
    </MenuTrigger>
    <MenuOptions customStyles={{
                        optionsWrapper: {
                            borderColor: 'yellow', borderWidth: 1
                        },
                        optionsContainer: [
                            formStyles.optionsContainer,
                            { borderColor: 'red', borderWidth: 1 }
                        ],

                    }}
    >
        {
            options.map((option) => (
                <View key={option.value} style={[formStyles.optionItemView, { borderColor: 'green', borderWidth: 1 }]}>
                    <MenuOption onSelect={() => onChangeCallback(option.value)}>
                        <Text style={formStyles.optionItemText}>
                            {option.label}
                        </Text>
                    </MenuOption>
                </View>
            ))
        }
    </MenuOptions>
</Menu>

);

最佳答案

尝试将 marginLeft 设为负值,例如 -10;这对我有用:

<MenuOptions
      optionsContainerStyle={{marginLeft: -20,}}
>

关于css - 将 react-native-popup-menu MenuOptions 右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53093271/

相关文章:

php - 下拉菜单不起作用

javascript - jQuery 函数在 Chrome 中不起作用

html - apache 无法访问 html 子目录并出现 404 错误

html - 在 HTML 中布置图像

ios - 我想在应用程序的非事件模式下接收通知时在主应用程序图标上增加角标(Badge)

react-native - React Navigation 缓存组件

javascript - 如何在 React Native 中访问文件系统?

react-native - wix/react-native-navigation 导航栏中的上下文弹出菜单

react-native - React Native 弹出菜单移动选项框