小编San*_*nee的帖子

悬停样式 '&:hover:{ }' 不适用于反应组件中的按钮

这些天我正在使用反应组件,并且在使用悬停样式设计我的一个按钮时遇到了一些问题。以下是我在组件中使用的代码片段。

const darkTheme = createMuiTheme({
    palette: {
        type: 'dark',
        secondary:amber
    },
    typography: {
        useNextVariants: true,
    }
});

const lightTheme = createMuiTheme({
    palette: {
        type: 'light',
        secondary:amber
    },
    typography: {
        useNextVariants: true,
    }
});
Run Code Online (Sandbox Code Playgroud)

上面是我正在使用的自定义主题。

class APIWidget extends Widget {

constructor(props) {
    super(props);

    this.styles = {
        button: {
            backgroundColor: amber[500],
            '&:hover': {
                backgroundColor: amber[700],
            },
            position: 'absolute',
            bottom: 20,
            right: 20
        },
    };
}

render() {
    return (
        <MuiThemeProvider theme={this.props.muiTheme.name === 'dark' ? darkTheme : lightTheme}>
                <Button variant="contained" color="secondary" style={this.styles.button}>
                    <ArrowBack …
Run Code Online (Sandbox Code Playgroud)

css reactjs react-component

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

react-component ×1

reactjs ×1