Media queries in styled-component declared with object

人盡茶涼 提交于 2021-02-08 14:01:30

问题


I write styled components like in react-native, as a js object:

const SectionTitle = styled.div({
  fontSize: '25px',
  display: 'flex',
})

Is it possible to use media queries with the above object style?


回答1:


Yes, this is possible. You just need to wrap your object keys with quotes to form a string from a media query rule.

For example:

const SectionTitle = styled.div({
  fontSize: '25px',
  display: 'flex',
  '@media(min-width: 788px)': {
    fontSize: '40px'
  }
})


来源:https://stackoverflow.com/questions/53443376/media-queries-in-styled-component-declared-with-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!