本文介绍了YUI重置CSS使< strong>< em>这不工作< / em>< / strong>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

YUI的中的此行对我造成了麻烦:

 地址,字幕,引用,代码,dfn,em,strong,th,var {
字体样式:正常;
font-weight:normal;
}

它使我的 em 不是斜体和我的不是粗体。这是好的。我知道如何在我自己的样式表中覆盖它。

  strong,b 
{
font-weight:bold;
}

em,i
{
font-style:italic;
}

问题出现在我有文本 em strong

  这是粗体,< em>,这是斜体,但不是粗体< / em> / strong> 

我的规则 strong 但是YUI的 em 规则使它再次正常。如何解决这个问题?

解决方案

如果你的强宣言来自YUI,你的应该重写它。你可以这样强制:

  strong,b,strong *,b * {font-weight:bold; } 
em,i,em *,i * {font-style:italic; }

如果您仍然支持IE7,您需要添加!important

  strong,b,strong *,b * {font-weight:bold!important; } 
em,i,em *,i * {font-style:italic!important; }

这项工作 - 自己看:



  / * YUI styles * / address,caption,cite,code,dfn,em,strong,th,var {font-style:正常; font-style:font-style:font-style:font-style:font-style:font-style:font-style:font-style:font-style: / code> 
 < strong>粗体< / strong> - < em>斜体< / em> - < strong> Bold和< em>斜体< / strong>  

b

This line in YUI's Reset CSS is causing trouble for me:

address,caption,cite,code,dfn,em,strong,th,var {
    font-style: normal;
    font-weight: normal;
}

It makes my em not italic and my strong not bold. Which is okay. I know how to override that in my own stylesheet.

strong, b
{
  font-weight: bold;
}

em, i
{
  font-style: italic;
}

The problem comes in when I have text that's both em and strong.

<strong>This is bold, <em>and this is italic, but not bold</em></strong>

My rule for strong makes it bold, but YUI's rule for em makes it normal again. How do I fix that?

解决方案

If your strong declaration comes after YUI's yours should override it. You can force it like this:

strong, b, strong *, b * { font-weight: bold; }
em, i, em *, i * { font-style: italic; }

If you still support IE7 you'll need to add !important.

strong, b, strong *, b * { font-weight: bold !important; }
em, i, em *, i * { font-style: italic !important; }

This works - see for yourself:

/*YUI styles*/
address,caption,cite,code,dfn,em,strong,th,var {
  font-style: normal;
  font-weight: normal;
}
/*End YUI styles =*/

strong, b, strong *, b * {
  font-weight: bold;
}

em, i, em *, i * {
  font-style: italic;
}
 <strong>Bold</strong> - <em>Italic</em> - <strong>Bold and <em>Italic</em></strong>

这篇关于YUI重置CSS使&lt; strong&gt;&lt; em&gt;这不工作&lt; / em&gt;&lt; / strong&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:31