css - 带有 css 的样式排版
问题描述
我正在尝试使用 CSS 文件对 Material UI 中的 Typography 进行样式设置,但我所做的样式并未应用于我的 React 网站。任何帮助将不胜感激!
我想用 className ".title-card" 来设置 Typography 的样式,下面你会找到对应的 js 和 css 文件
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import Paper from '@material-ui/core/Paper';
import Typography from '@material-ui/core/Typography';
import ButtonBase from '@material-ui/core/ButtonBase';
import stockPhoto from '../images/home-stock-image.png';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import { CardHeader } from '@material-ui/core';
import '../styling/SmallCard.css'
const useStyles = makeStyles((theme) => ({
root: {
flexGrow: 1,
},
paper: {
padding: theme.spacing(2),
margin: 'auto',
maxWidth: 500,
},
image: {
width: 128,
height: 128,
},
img: {
margin: 'auto',
display: 'block',
maxWidth: '100%',
maxHeight: '100%',
},
//having trouble setting dimensions of card
style:
{minWidth: "5000px", margin: '12px'},
}));
var cardStyle = {
width: '424px',
height: '466px',
left: '64px',
top: '761px'
}
export default function SmallCard({submission}) {
const classes = useStyles();
return (
<div>
{ /*{submission.title}*/ }
<Card style={cardStyle}>
<CardMedia
component="img"
alt="Contemplative Reptile"
height="180"
image={stockPhoto}
title="Contemplative Reptile"
/>
<CardContent>
<Typography className=".title-card" gutterBottom variant="h5" component="h2">
London, England
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
3 Apr 1944
</Typography>
</CardContent>
</Card>
</div>
);
}
.title-card {
font-family: Open Sans;
font-style: normal;
font-weight: bold;
font-size: 24px;
line-height: 33px;
}
我想应用相应的字体和文本更改但未应用
解决方案
必须引用带空格的字体系列:
font-family: "Open Sans";
还要修正你的错字:
<Typography className=".title-card
删除点。
推荐阅读
- php - 如何像在 python 中一样在 PHP 中执行校验和?
- python - 如何解决 Fenics 示例 ft06_elasticity.py 中未定义名称“nabla_div”错误?
- cluster-computing - pcs 在同时启动两台机器时在主节点中启动它们之前不会停止伙伴节点中的故障转移资源
- excel - 我能否以编程方式启用和禁用存储在 SharePoint 中并链接到 ms-access 的 xlsx 文件的 ms-excel 文件共享/共同创作?
- java - 我们可以使用包装类将 int 转换为 Byte 而不进行类型转换吗?
- javascript - React-DOM 自动触发 onClick 处理程序
- typescript - 试图让 fromEntries 类型正确
- mysql - 经典 ASP 遗留系统为 MySQL 8.0 中的所有整数返回 0
- c++ - Win32 更新后重启应用
- android - 用 GLES 编写的应用程序是否与新的 Vulkan 设备兼容