javascript - 如何更改 Rebass 的断点?
问题描述
我正在尝试更改默认断点,但它不起作用。我遵循了文档并使用了ThemeProvider
,但 Rebass 仍在使用默认断点。由于这个错误emotion-theming
,我没有使用,而是使用:@emotion/react
Error: `emotion-theming` has been removed and all its exports were moved to `@emotion/react` package
我使用这些版本:
"@emotion/react": "^11.1.5",
"rebass": "^4.0.7"
我的代码
_app.js
import { ThemeProvider } from "@emotion/react";
const theme = {
breakpoints: ["768px", "1024px"]
};
export default function MyApp({ Component, pageProps }) {
return (
<ThemeProvider theme={theme}>
<Component {...pageProps} />
</ThemeProvider>
);
}
index.js
import { Box, Flex } from "rebass";
export default function IndexPage() {
return (
<Flex sx={{ flexDirection: ["column", "column", "row"] }}>
<Box sx={{ width: ["100%", "100%", "50%"], marginBottom: [10, 25, 0] }}>
Hello
</Box>
<Box sx={{ width: ["100%", "100%", "50%"] }}>World</Box>
</Flex>
);
}
代码沙盒
我还创建了一个用于复制的沙箱:https ://codesandbox.io/s/rebass-themeprovider-wcc6b
期望
断点应该是768px
and1024px
而不是40em
and 52em
。
解决方案
推荐阅读
- python - 尝试连接时 Python 脚本失败
- latex - 如何在gnuplot中的符号上加一个点?
- r - 双变量 Probit/logit R:如何使用“zeligverse”包找到所有系数和边际效应
- sql - 混淆是否使用 HAS 或 BELONGS TO 1:1
- docker - nginx/docker 路由配置
- c# - .NET Standard F# 库无法正确存储非英文字符
- php - 斜杠后的 URL 中的文本作为参数
- java - 如何从java代码中判断两个类之间的关系?(关联与依赖)
- java - 我无法仅从屏幕截图中获取照片
- assembly - 从 GP regs 加载 xmm