样式组件中的 CSS calc()

R. *_*sch 7 javascript css reactjs styled-components

试试这个:

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

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

kia*_*hws 22

关于 CSS 的一个有趣提示calc

+/- 之间需要空格

意义:

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

应该管用