我试图将css应用于一个排版元素,但它什么也不做;我在另一个div元素上尝试了相同的css,它可以工作,但它根本不适用于排版。这是我的排版元素:
<Typography
variant="title"
classname={classes.detailTitle}
>
Details:
</Typography>这是我的css:
detailTitle: {
textDecoration: 'underline'
}有什么线索吗?
发布于 2018-04-18 16:29:02
您的排版html中有一个小错误,它需要在有类名的地方说classname。这是react特定的,要获得更多信息,请看这里的https://reactjs.org/docs/dom-elements.html
发布于 2020-02-05 08:53:01
您可以使用Material组件的classes属性来设置其样式。检查此页面https://material-ui.com/api/typography/#css
示例:
const useStyles = makeStyles((theme) => ({
h3: {
fontSize: '48px',
fontWeight: '600'
},
})
)
const TextComp = (props) => {
const classes = useStyles()
return (
<Typography
variant='h3' component='h3'
classes={{ h3: internalClasses.h3 }}
>
{header}
</Typography>
)
}https://stackoverflow.com/questions/49903004
复制相似问题