【问题标题】:Can CSS override the bold style of an existing <b> bold tag?CSS 可以覆盖现有 <b> 粗体标签的粗体样式吗?
【发布时间】:2011-04-24 16:24:52
【问题描述】:

我有一个脚本,它的面包屑样式超出了我的范围(核心文件),我想使用 CSS 覆盖它的所有样式。文本如下所示:

<div class="someclass">
<b>Some Text</b>
</div>

我想设置&lt;div&gt; 的样式以使其忽略粗体标记。在不删除 &lt;b&gt; 标记并仅使用外部 CSS 的情况下是否可以这样做?

【问题讨论】:

    标签: html css typography


    【解决方案1】:

    是的:

    .someClass b {
        font-weight: normal;
    }
    

    【讨论】:

    • 哈哈,太简单了。我有很多东西要学:)谢谢!
    【解决方案2】:

    如果您有一个字体粗细很多的大型项目:粗体;引用,您可以覆盖 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>

    用法:

    body {
        font-family: 'Open Sans';
    }
    

    【讨论】:

      猜你喜欢
      • 2011-10-29
      • 2020-12-23
      • 2012-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 2011-07-07
      • 1970-01-01
      相关资源
      最近更新 更多