如果CSS中使用了回退字体,是否可以使用触发器?
我正在用CSS创建如果CSS中使用了回退字体,是否可以使用触发器?,css,font-face,Css,Font Face,我正在用CSS创建@font-face规则。我所做的是创建了两个规则,一个用于普通字体,另一个用于粗体字体。像这样: @font-face { font-family: 'CenturyGothicRegular'; src: url('/static/fonts/gothic_2-webfont.eot'); src: url('/static/fonts/gothic_2-webfont.eot?#iefix') format('embedded-opentype')
@font-face
规则。我所做的是创建了两个规则,一个用于普通字体,另一个用于粗体字体。像这样:
@font-face
{
font-family: 'CenturyGothicRegular';
src: url('/static/fonts/gothic_2-webfont.eot');
src: url('/static/fonts/gothic_2-webfont.eot?#iefix') format('embedded-opentype'),
url('/static/fonts/gothic_2-webfont.woff') format('woff'),
url('/static/fonts/gothic_2-webfont.ttf') format('truetype'),
url('/static/fonts/gothic_2-webfont.svg#CenturyGothicRegular') format('svg');
font-weight: normal;
font-style: normal;
}
... and another for 'CenturyGothicBold'
然后,我将网站的整体字体设置为Verdana默认字体,如下所示:
body
{
font-family: "CenturyGothicRegular", Verdana;
font-size: 14px;
}
并为
制定了一个小规则,因此,将使用粗体版本,而不是将正常重量版本设置为粗体(这似乎只是拉伸了它):
strong
{
font-weight: normal;
font-family: 'CenturyGothicBold';
}
我在这里可以预见的一个问题是,如果字体默认为Verdana,粗体将不存在
是否有一种方法可以为
指定一组新规则,这些规则仅在字体默认为Verdana时适用?无需找到触发器来查看是否使用了回退字体
您需要做的是使用相同的姓氏在@font-face
规则中设置字体权重。所以你现在可以称之为百年古诗:
这将把两种字体组合成一个字体系列
,允许它像任何其他字体系列
一样工作,即当您将其设置为粗体
时,它将显示字体的粗体版本等。当您有多个字体系列时,仅使用字体重量
将不起作用重量
,如轻、超轻、浓缩黑体、半黑体等。@marty:如果需要更多解释,请告诉我。我觉得不错,只要给我一个实施的机会,我会回复你:)勒索。。(如果没有我的消息,任何人都可以读到这条消息。是tw16做的。)。这是你的+1:)现在我在玩等待游戏:)
@font-face {
font-family: 'CenturyGothic'; /* this used to be CenturyGothicRegular */
src: url('/static/fonts/gothic_2-webfont.eot');
src: url('/static/fonts/gothic_2-webfont.eot?#iefix') format('embedded-opentype'),
url('/static/fonts/gothic_2-webfont.woff') format('woff'),
url('/static/fonts/gothic_2-webfont.ttf') format('truetype'),
url('/static/fonts/gothic_2-webfont.svg#CenturyGothicRegular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'CenturyGothic'; /* this used to be CenturyGothicBold but the urls still need to point to the files they were pointing at */
src: url('/static/fonts/gothic_2-webfont.eot');
src: url('/static/fonts/gothic_2-webfont.eot?#iefix') format('embedded-opentype'),
url('/static/fonts/gothic_2-webfont.woff') format('woff'),
url('/static/fonts/gothic_2-webfont.ttf') format('truetype'),
url('/static/fonts/gothic_2-webfont.svg#CenturyGothicRegular') format('svg');
font-weight: bold;
}
body{
font-family: "CenturyGothic", Verdana;
font-size: 14px;
}
strong{
font-weight: bold;
}