样式组件中的 CSS calc()

IT技术 javascript css reactjs styled-components
2021-04-27 11:59:31

试试这个:

const styledDiv = styled.div`
  ${props => props.takeViewportHeight && `min-height: calc(100vh-16px);`}
`

它不工作。我是否在样式组件中遗漏了有关 calc 的内容?

1个回答

关于 CSS 的一个有趣提示calc

+/- 之间需要空格

意义:

const styledDiv = styled.div`
  ${props => props.takeViewportHeight && `min-height: calc(100vh - 16px);`}
`

应该管用