javascript - 在 Material UI Typography 中将内容与变体居中对齐作为标题

标签 javascript css reactjs material-ui typography

我有两个带有默认变体和标题变体的 Typography 元素。我如何使用 align="center" 属性将内容居中,并将变体作为标题,因为这似乎不起作用。

  render() {
    return (
      <div>
        <Typography align="center">Centered text</Typography>
        <Typography color="textSecondary" variant="caption" align="center">A Caption!</Typography>
      </div>
    );
  }

我使用 StackBlitz 创建了一个工作示例.有人可以帮忙吗?

最佳答案

import React from "react";
import Typography from "@material-ui/core/Typography";

export default function DisableElevation() {
  return (
    <div>
      <Typography align="center">Centered text</Typography>
      <Typography
        display="block"
        color="textSecondary"
        variant="caption"
        align="center"
      >
        A Caption!
      </Typography>
    </div>
  );
}

关于javascript - 在 Material UI Typography 中将内容与变体居中对齐作为标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63140186/

相关文章:

javascript - 无法加载路由模块 requirejs? Durandal bug ?

html - 通过 CSS 更改 PNG 图像的颜色?

javascript - 如何制作像reddit网站一样的固定侧边栏?

javascript - Firebase 电话身份验证和链接

javascript - ReactJS - 图像未显示在 Material 表的自定义列中

javascript - 在 Firefox 中捕获页面的 x 和 y 坐标

JavaScript 窗口 #hash Action

javascript - Select options 2 "columns"well aligned despite left column's longest length 不顾左栏的最长长度

jquery - 事件页面上的 ListItem css 更改

javascript - react ,正确更新复选框