gpt4 book ai didi

css - 如何在正文中使用一种字体表示正常粗细而另一种字体表示粗体?

转载 作者:行者123 更新时间:2023-11-28 09:49:43 26 4
gpt4 key购买 nike

我正在尝试将字体“open sans”应用到我的网站。我想对非粗体文本使用“open sans regular”,对粗体文本使用“open sans bold”字体,对斜体文本使用“open sans italic”,最后对“open sans bold italic”使用粗体和斜体的文本。我不想设置类,而只是让它们应用于整个网站。

这是我试过的代码,但它只是应用“open sans italic”,我认为“open sans bold italic”适用于所有内容,即使它不应该是斜体..

@font-face {
font-family: 'opensans';
src: url('opensans-regular-webfont.eot');
src: url('opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-regular-webfont.woff') format('woff'),
url('opensans-regular-webfont.ttf') format('truetype'),
url('opensans-regular-webfont.svg#open_sansregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'opensans';
src: url('opensans-semibold-webfont.eot');
src: url('opensans-semibold-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-semibold-webfont.woff') format('woff'),
url('opensans-semibold-webfont.ttf') format('truetype'),
url('opensans-semibold-webfont.svg#open_sanssemibold') format('svg');
font-weight: bold;
}
@font-face {
font-family: 'opensans';
src: url('opensans-italic-webfont.eot');
src: url('opensans-italic-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-italic-webfont.woff') format('woff'),
url('opensans-italic-webfont.ttf') format('truetype'),
url('opensans-italic-webfont.svg#open_sansitalic') format('svg');
font-style: italic, oblique;
}
@font-face {
font-family: 'opensans';
src: url('opensans-semibolditalic-webfont.eot');
src: url('opensans-semibolditalic-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-semibolditalic-webfont.woff') format('woff'),
url('opensans-semibolditalic-webfont.ttf') format('truetype'),
url('opensans-semibolditalic-webfont.svg#open_sanssemibold_italic') format('svg');
font-weight: bold;
font-style: italic, oblique;
}
body {
font-family:'opensans';
font-size:78%;
}

这里是问题的一个例子,注意所有的字体都是斜体,而它不应该是:http://www.bbmthemes.com/themes/modular/

最佳答案

好的,我想出了我自己的问题。必须有一个非常具体的顺序才能使其正常工作。您需要按以下顺序定义它们:

正常斜体大胆的粗斜体

所以 css 看起来像这样:

@font-face {
font-family: 'opensans';
src: url('opensans-regular-webfont.eot');
src: url('opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-regular-webfont.woff') format('woff'),
url('opensans-regular-webfont.ttf') format('truetype'),
url('opensans-regular-webfont.svg#open_sansregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'opensans';
src: url('opensans-italic-webfont.eot');
src: url('opensans-italic-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-italic-webfont.woff') format('woff'),
url('opensans-italic-webfont.ttf') format('truetype'),
url('opensans-italic-webfont.svg#open_sansitalic') format('svg');
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: 'opensans';
src: url('opensans-semibold-webfont.eot');
src: url('opensans-semibold-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-semibold-webfont.woff') format('woff'),
url('opensans-semibold-webfont.ttf') format('truetype'),
url('opensans-semibold-webfont.svg#open_sanssemibold') format('svg');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'opensans';
src: url('opensans-semibolditalic-webfont.eot');
src: url('opensans-semibolditalic-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-semibolditalic-webfont.woff') format('woff'),
url('opensans-semibolditalic-webfont.ttf') format('truetype'),
url('opensans-semibolditalic-webfont.svg#open_sanssemibold_italic') format('svg');
font-weight: bold;
font-style: italic;
}
body {
font-family:'opensans';
font-size:78%;
}

这篇文章帮我弄明白了 http://www.456bereastreet.com/archive/201012/font-face_tip_define_font-weight_and_font-style_to_keep_your_css_simple/

关于css - 如何在正文中使用一种字体表示正常粗细而另一种字体表示粗体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18425414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com