首页 > 解决方案 > 如何更正 CSS 文件中的 $ 标记?

问题描述

我的项目中有 CSS const,然后在显示错误的最后一行插入“$”符号。我该如何解决?

const NavBox = (props: { children: React.ReactNode }) => { return (
<div
  css={css`
    display: flex;
    height: 100%;
    justify-content: flex-end;
    align-items: center;
  
    @media (max-width: 768px) {
      flex-direction: column;
      position: fixed;
      width: 100%;
      justify-content: flex-start;
      padding-top: 10vh;
      background-color: #fff;
      transition: all 0.3s ease-in;
      top: 8vh;
      left: ${props => (props.open ? "-100%" : "0")};
    }
  `}
  {...props}
></div>

) }

标签: cssreactjscss-transitionstransform

解决方案


删除 lambda 并执行以下操作:

left: ${props.open ? "-100%" : "0"};

推荐阅读