2009-10-08 54 views
0

我在字段集内部有一个字段集。每种类型的字段集在悬停时都会改变颜色。在Firefox中很好用,但在IE8兼容模式下,IE8和IE8中,当我将鼠标悬停在子字段上时,它会跳转(看起来有些填充被删除,但这不是我的CSS所说的)。在IE8中悬停时防止跳跃字段集

有人可以帮我弄清楚如何防止IE中的跳跃效应?为什么子集字段集在跳过时跳转,而不是父字段集?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head> 
    <style type="text/css"> 
     fieldset.property { background-color: #EDF5FF; } 
     fieldset.property:hover { background-color: #C1DDFF; } 
     fieldset.service:hover { background-color:#EDF5FF; } 
    </style> 
</head> 
<body> 
    <fieldset class="property"> 
     Parent fieldset<br /> 
     Parent fieldset<br /> 
     Parent fieldset<br /> 
     <fieldset class="service"> 
      Child<br /> 
      Child<br /> 
      Child<br /> 
     </fieldset> 
     Parent fieldset<br /> 
     Parent fieldset<br /> 
     Parent fieldset<br /> 
    </fieldset> 
</body> 

回答

3

我也一样,我不确定到底为什么IE会将子元素这种方式,而是由专门定义填充和很多时候,利润率为好,THI s是可以预防的。

fieldset {margin:0; padding:0;}

+0

任何人都知道这是否被认为是在IE浏览器的错误,或者是由设计? – slolife 2009-10-08 20:29:00

+0

我不认为这是一个错误。每个浏览器都以不同的方式呈现边距和填充。通过为这两个属性定义一个特定的值,每个浏览器都会根据CSS进行渲染。 – Slevin 2009-10-09 13:08:38

+0

不同的填充/边距不是一个错误。这对我来说很好,并且会教会我将来使用重置css。悬停时出现的跳跃式儿童字段集似乎是一个错误IMO。 无论如何,感谢您的帮助 – slolife 2009-10-09 21:17:02

0

我仍然不知道为什么IE8使孩子神经质,但我发现修复:

如果我添加一个风格上明确设置一个字段的填充,该字段集当鼠标悬停保持不变:

/* Add to make rendering in IE and Firefox the same /* 
fieldset { padding:2px; }