How to use pseudo selectors in material-ui?

后端 未结 3 813
天命终不由人
天命终不由人 2021-02-11 14:48

I have been trying to achieve the simple thing. I was trying to show/hide my component in the material UI v1 with pseudo selectors but somehow it

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-11 15:04

    The solution that worked for me is the following

    export const useStyles = makeStyles(theme=>({
            header:{
                position: "relative!important",
                background: "linear-gradient(150deg,#7795f8 15%,#6772e5 70%,#555abf 94%)",
                margin: -50,
                padding: -50,
                height: 500,
            },
    
            span: props => ({
                padding:50,
                background: "rgba(255, 255, 255, .1)",
                borderRadius: "50%",
                position: "absolute",
                "&:nth-child(1)": {
                    left: "-4%",
                    bottom: "auto",
                    background: "rgba(255, 255, 255, .1)"
                },
                "&:nth-child(2)":{
                    right: "4%",
                    top: "10%",
                    background: "rgba(255, 255, 255, .1)"
                },
                "&:nth-child(3)":{
                    top: 280,
                    right: "5.66666%",
                    background: "rgba(255, 255, 255, .3)"
                },
                "&:nth-child(4)":{
                    top: 320,
                    right: "7%",
                    background: "rgba(255, 255, 255, .15)"
                },
                "&:nth-child(5)":{
                    top: "38%",
                    left: "1%",
                    right: "auto",
                    background: "rgba(255, 255, 255, .05)"
                },
                "&:nth-child(6)": {
                    width: 200,
                    height: 200,
                    top: "44%",
                    left: "10%",
                    right: "auto",
                    background: "rgba(255, 255, 255, .15)"
                },
                "&:nth-child(7)": {
                    bottom: "50%",
                    right: "36%",
                    background: "rgba(255, 255, 255, .04)"
                },
                "&:nth-child(8)": {
                    bottom: 70,
                    right: "2%",
                    background: "rgba(255, 255, 255, .2)"
                },
                "&:nth-child(9)": {
                    bottom: "1%",
                    right: "2%",
                    background: "rgba(255, 255, 255, .1)"
                },
                "&:nth-child(10)": {
                    bottom: "1%",
                    left: "1%",
                    right: "auto",
                    background: "rgba(255, 255, 255, .05)"
                }
    
            }),
    

提交回复
热议问题