我正在尝试更改我的应用程序的全局字体系列,但我无法让它工作。
我正在使用Semantic-UI-React所以我认为这可能是问题所在,但是当我查找src/site/globals/site.variables
(其他解决方案引用的东西)来更改全局变量时,我意识到我没有在Semantic中包含这些文件 - UI-React节点模块。我还尝试在我的应用程序的!important
上使用#root
以及包含我所有组件和其他较低级别的.app
,但它只更改了我的Semantic-Modal中的代码。
我在frontend_react/public/index.html
中导入了字体
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="/styles.css" >
<link href="https://fonts.googleapis.com/css?family=Cinzel:700,900" rel="stylesheet">
<style>
@import url('https://fonts.googleapis.com/css?family=Cinzel:700,900');
#root {
font-family: 'Cinzel', serif !important;
}
</style>
<title>Three Seeds Tarot</title>
然后我调用了/App.css
中的字体。我也用body, html
选择器以相同的方式和page
选择器调用它无济于事。
.App {
text-align: center;
background-image: url('http://2.bp.blogspot.com/-kX_5_Cqch4g/UmBAsMV4krI/AAAAAAAADjA/XEJnfAq1Dsg/s1600/ProtectionKamea300dpi(a3).jpg');
font-family: 'Cinzel', serif !important;
}
这是我的/App.js
组件渲染功能:
render() {
const user = this.props.user
return (
<div className='App'>
<div id='nav-bar'>
<NavBar/>
</div>
<div className='page'>
{!user.loggedIn ? <div>
<header className='App-header'>
<marquee scrollamount='5' direction='right'><img src={image} className='App-logo' alt='logo' /></marquee>
</header>
</div> : null
}
<Switch>
<Route path='/readings/new' component={ NewReading } />
<Route path='/readings' component={ ReadingSplash } />
<Route path='/cards' component={ CardList }/>
<Route exact path='/profile' component={ Profile } />
<Route exact path='/' component={ Welcome } />
<Route exact path='/login' component={ Login } />
<Route exact path='/signup' component={ Signup } />
</Switch>
</div>
</div>
);
}
CSS更改工作的唯一地方是我的语义UI模式中的<p>
标记:
render() {
return (
<div className='card-image'>
<Modal
size='large'
trigger={
<div className="ui medium images" >
<img className="single-card" src={this.getImage(this.props.card.name)} alt="No Image Found" onClick={this.handleClick} />
</div>}
style={inlineStyle.modal}
>
<Modal.Header>{this.props.card.name}</Modal.Header>
<Modal.Content >
<Image wrapped size='medium' src={this.getImage(this.props.card.name)} floated='left' />
<Modal.Description>
<Header>{capitalize(this.props.card.card_type)} Arcana</Header>
<p>Meaning Upright: {this.props.card.meaning_up} </p>
<p>Meaning Reversed: {this.props.card.meaning_rev} </p>
<p>Description: {this.props.card.desc} </p>
</Modal.Description>
</Modal.Content>
<Modal.Actions>
{/* <Button primary onClick={this.modalClose}>Close</Button> */}
</Modal.Actions>
</Modal>
</div>
)
}
因此,总而言之,我想更改全局字体。我尝试使用!important
,我知道这不是最好的解决方案,但我发现的所有其他解决方案都引用了在src/site/globals/site.variables
文件夹中更改Semantic UI React的全局变量,我似乎没有。
site.variables
文件是CSS的Semantic UI构建工具中的单独文件。如果您的项目还不包括包含所有Gulp构建工具的主要Semantic UI项目,那么您将不会拥有任何这些文件。更改该字体的唯一方法是重新编译自己的CSS。
听起来您正在导入已在应用程序早期编译为CSS导入的语义UI样式。只要您在SUI导入CSS后在body标签上定义所需的字体,它就应该优先。如果您想确定,您还可以组合选择器以增加特异性。
body #root {
font-family: "MyFont", ...your fallback stack
}