【问题标题】:CSS and IE9 : tags uncorrectly interpretedCSS 和 IE9:标签被错误解释
【发布时间】:2012-04-13 14:59:49
【问题描述】:

我正在做一个关于化学安全象形图的 MCQ 的小网站。

学生阅读问题、选择答案、验证并阅读另一页上的答案。

很简单。

正确答案用绿色书写,如果学生回答正确,还会出现绿色“好答案”信息。错误的选择会用红色写成“错误答案”。

该网站在firefox上完全正确,但颜色和字体在IE9上显示不正确。

我在部分中使用标签:

<style>
  itsfalse {
    font-family: "Times New Roman",serif; 
    font-weight: bold; 
    color:#00A000;
  }
  itstrue { 
    font-family: "Times New Roman",serif; 
    font-weight: bold; 
    color:#FF0000;
  }
  goodans {
    font-family: "Arial",sans-serif; 
    font-weight: bold; 
    color: #00A000; 
    font-size:larger;
  }
  badans {
    font-family: "Arial",sans-serif;
    font-weight: bold;
    color:#FF0000;
  }
</style>

For instance when the choice was right I'd have something like :

<itstrue>[the right answer]</itstrue> 
<goodans>Good answer!</goodans>

正如我所说,Firefox 正确读取它,而 IE 读取标签之间的内容但不使用样式。

如果我不使用 CSS 而是使用良好的 HTML 及其 &lt;font&gt;&lt;/font&gt;,没问题,但它有点重。

http://hildoceras.fr/quizz 上的 PS 网站(在法语标签是 vrai、faux、bon、mau 在correction.php 中)

【问题讨论】:

  • 可能是什么问题?您不是在编写 HTML。 坚持使用 HTML。

标签: css internet-explorer fonts tags


【解决方案1】:

我认为你的主要问题是你在编造元素。一些浏览器会很好地解析它,而另一些浏览器会忽略为这些元素所做的任何样式声明。这就是 HTML5 shim 存在的原因。

尝试将标准 HTML 元素(&lt;p&gt;&lt;div&gt;)与“itstrue”和“goodans”等结合使用。

【讨论】:

    【解决方案2】:

    你不应该使用自定义的 HTML 标签,如果你这样做了,它就不再是 HTML。

    坚持使用 HTML 并使用 CSS 类,如下所示:

        <style type="text/css"> 
        .itsfalse {font-family:"Times New Roman",serif; font-weight:bold; color:#00A000;} 
        .itstrue {font-family:"Times New Roman",serif; font-weight:bold; color:#FF0000;} 
        .goodans {font-family:"Arial",sans-serif; font-weight:bold; color:#00A000; font-size:larger;} 
        .badans {font-family:"Arial",sans-serif; font-weight:bold; color:#FF0000;} 
        </style>
        ...
        <span class="itstrue"> [the right answer] </span> 
        <span class="goodans">&nbsp;&nbsp;&nbsp;Good answer !</span>
    

    【讨论】:

    • 谢谢大家,我没有意识到严格的 html 无法读取“自制”标签。课程工作正常。我想要的东西更重,但复制粘贴会使更改更容易。再次感谢。
    猜你喜欢
    • 2012-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多