Inline CSS styles in React: how to implement a:hover?

前端 未结 18 904
星月不相逢
星月不相逢 2020-11-28 21:51

I quite like the inline CSS pattern in React and decided to use it.

However, you can\'t use the :hover and similar selectors. So what\'s the best way to

18条回答
  •  时光说笑
    2020-11-28 22:06

    Late to party but come with solution. You can use "&" to defines styles for hover nth Child etc:

    day: {
        display: "flex",
        flex: "1",
        justifyContent: "center",
        alignItems: "center",
        width: "50px",
        height: "50px",
        transition: "all 0.2s",
        borderLeft: "solid 1px #cccccc",
    
        "&:hover": {
          background: "#efefef"
        },
        "&:last-child": {
          borderRight: "solid 1px #cccccc"
        }
    },
    

提交回复
热议问题