Html CSS 可以覆盖现有 <b> 粗体标签的粗体样式吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5771727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can CSS override the bold style of an existing <b> bold tag?
提问by Adrian M.
I have a script that has a breadcrumb styled outside of my reach (core files), and I want to override all its styling using CSS. The text looks like this:
我有一个脚本的面包屑样式超出了我的范围(核心文件),我想使用 CSS 覆盖其所有样式。文本看起来是这样的:
<div class="someclass">
<b>Some Text</b>
</div>
I want to style the <div>
to make it ignore the bold tag. Is this possible without removing the <b>
tag and just using external CSS?
我想设置样式<div>
以使其忽略粗体标记。这是否可能不删除<b>
标签而仅使用外部 CSS?
回答by SLaks
Yes:
是的:
.someClass b {
font-weight: normal;
}
回答by alexqc
If you have a large project with many font-weight: bold; references, you can override the eitre font:
如果您有一个包含许多字体粗细的大型项目:粗体;参考,您可以覆盖 eitre 字体:
/* some core files */
b {
font-weight: bold;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Light'), local('OpenSans-Light'), url(https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhp.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
body {
font-family: 'Open Sans';
}
/* no override */
body .someclass2 {
font-family: sans-serif;
}
<body>
<div class="someclass">
<b>Some Text</b>
</div>
<div class="someclass2">
<b>Some Text</b>
</div>
</body>
Usage:
用法:
body {
font-family: 'Open Sans';
}