【发布时间】:2019-08-23 14:13:54
【问题描述】:
我想使用Styled-Components 全局设置font-family。我使用了createGlobalStyle并将字体设置为body,但是body里面的div没有继承字体。
这是我的 Styled-components 正文:
import {createGlobalStyle} from 'styled-components';
export const AppRoot = createGlobalStyle`
body {
@import url('../../font.css');
font-family: Vazir !important;
direction: rtl;
text-align: right;
cursor: default;
}
`;
这是我的使用方法:
import {AppRoot} from './StyledComponents';
ReactDOM.render (
<Fragment>
<AppRoot/>
<App />
</Fragment>,
document.getElementById ('root')
);
【问题讨论】:
标签: css reactjs styled-components