css - 网格项“链接”未按预期居中
问题描述
这是一个使用 Material UI 的 TypeScript React 项目。我想将链接组件与此处复制"Send emails to new applicants →"
的文本一样居中。
但是,在我的本地代码库中,相同的代码会像下面这样居中中断。
我也意识到了一个奇怪的行为。对于我的组件Grid
周围的 item 元素的属性,Link
居中中断时:
<Grid item xs={12}>
居中在以下情况下起作用:<Grid item>
这一定意味着我的代码的另一部分正在阻止该项目居中。
所以我检查了以下内容,
- 我当前页面的样式表与布局无关。
<WrapperPage>
不包含任何样式
但是我应该检查代码中的其他地方吗?有什么推荐的方法吗?
这是一个使用 Material UI 的 TypeScript React 项目。Link
组件来自 Material UI,来自RouterLink
React Router。
实际代码是这样的。
SubmittedApplications.tsx
import { Box, Card, Grid, Typography, Link } from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
...
<WrapperPage>
<Grid container justifyContent="center" spacing={2}>
<Grid item xs={12}>
<Typography variant="h3" align="center">
Submitted Applications
</Typography>
</Grid>
<Grid item xs={12}>
<Link
component={RouterLink}
to="/sendemail"
variant="h5"
align="center"
>
Send emails to new applicants →
</Link>
</Grid>
</Grid>
...
</WrapperPage>
解决方案
推荐阅读
- javascript - 我在 node.js 中使用 Promise 的错误在哪里
- javascript - 自 2 月 20 日起适用于第 3 方 cookie 的 Samesite 和 Secure
- oracle - 将 Oracle 加密功能移植到 Postgres
- erlang - Erlcloud SQS 消息未发送
- ruby-on-rails - 需要在shopify APP中设置SameSite Cookie
- time-complexity - 我是否正确计算了big-o?
- database-design - 多个多对一关系到一张表
- seaborn - 使用seaborn plots制作的图形在彼此重叠时太紧
- javascript - 如何为不同的 Vue 布局使用不同的资源?
- laravel - 在 Kubernetes pod 中,不能强制 Laravel Echo(使用 Pusher)通过端口 6001 协议而不是端口 443 上的 wss 连接