CSS和IE9:标签被错误地解释

时间:2012-04-13 14:59:49

标签: css internet-explorer fonts tags

我正在做一个关于化学安全象形图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>

例如,当选择正确时,我会有类似的东西:

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

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

如果我不使用CSS但是很好的'HTML及其<font></font>,没问题,但它有点沉重。

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

2 个答案:

答案 0 :(得分:1)

我认为你的主要问题是你在制作元素。有些浏览器会解析这个很好,而其他浏览器会忽略为这些元素做出的任何样式声明。这就是HTML5垫片存在的原因。

尝试将标准HTML元素(<p><div>)与一起使用,例如“itstrue”和“goodans”。

答案 1 :(得分:1)

如果您使用自定义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>