css - 使用样式组件的媒体查询中的语法问题

标签 css reactjs

我有一个小问题,我有 2 个范围的媒体查询没有被读取,我认为我在某处有语法错误。我会粘贴一些代码

const size = {
  mobileS: '320px',
  mobileM: '375px',
  mobileL: '425px',
  ipad: '768px',
  tablet: '1024px',
  laptop: '1024px',
  laptopL: '1330px',
  desktop: '2560px',
};

const device = {
  mobileS: `(max-width:${size.ipad})`,
  ipad: `(min-width: ${size.ipad} and max-width:${size.tablet})`,
  tablet: `(min-width: ${size.tablet} and max-width:${size.laptopL})`,
  desktop: `(min-width: ${size.laptopL})`,
};

export default device;

无法读取 ipad 和平板电脑屏幕,我认为这是由于我声明这 2 台设备的最小和最大宽度的方式存在语法错误。 如果有人可以帮助,请

最佳答案

试试吧。看括号:

ipad: `(min-width: ${size.ipad}) and (max-width:${size.tablet})`,
tablet: `(min-width: ${size.tablet}) and (max-width:${size.laptopL})`,

关于css - 使用样式组件的媒体查询中的语法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59677662/

相关文章:

javascript - RxJS 和 React 的 setState - 延迟函数执行直到订阅

javascript - 在同一个 promise 中将用户和头像 URL 相互链接

css - 动态 block 内的响应图像

html - 某些浏览器中缺少表格边框。(边框折叠)

javascript - 如何使文本区域元素看起来像普通文本

javascript - 如何为不同高度的元素制作网格?

javascript - 如何在鼠标悬停时更改 setInterval() 回调函数不断修改的元素的值?

javascript - 类型错误 : Cannot read property 'focus' of undefined in ReactJS

javascript - 如何按对象数组中的任何属性过滤数据?

reactjs - 如何在保持状态的同时更改组件顺序?