材料UI自定义断裂点不起作用
我使用 Material UI 为我的媒体查询提供的默认断点,然后添加了一个断点(移动设备:400),所有其他断点都工作正常,除了当我达到 400px 的宽度时,更改不会生效点,我在这里做错了什么吗?
const theme = createTheme({
breakpoints: {
values: {
xs: 0,
mobile: 400,
sm: 600,
md: 900,
lg: 1200,
xl: 1536,
},
},
在下面,当屏幕达到 600px 宽度时,MQsm 值变为 'true' ,但是当我达到 400px 宽度时,MQmb 不会改变。
const Navbar = (props) => {
const cartQuantity = useSelector((state) => state.cart.totalQuantity);
const classes = useStyles();
const theme = useTheme();
const MQsm = useMediaQuery(theme.breakpoints.down("sm")); //600px
const MQmb = useMediaQuery(theme.breakpoints.down("mobile")); //360px
console.log(MQsm);
console.log(MQmb);
I was using the default breakingpoint provided by Material UI for my media queries , then added one more breaking point (mobile : 400) , all the other breaking points works fine except when i reach to the width of 400px the changes doesnt take effect at that point , am i doing anything wrong here?
const theme = createTheme({
breakpoints: {
values: {
xs: 0,
mobile: 400,
sm: 600,
md: 900,
lg: 1200,
xl: 1536,
},
},
at below when the screen reachs 600px width MQsm value turns to 'true' , but when i reach the width of 400px MQmb doesnt change.
const Navbar = (props) => {
const cartQuantity = useSelector((state) => state.cart.totalQuantity);
const classes = useStyles();
const theme = useTheme();
const MQsm = useMediaQuery(theme.breakpoints.down("sm")); //600px
const MQmb = useMediaQuery(theme.breakpoints.down("mobile")); //360px
console.log(MQsm);
console.log(MQmb);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论