Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html IE8中没有字段集填充顶部_Html_Css_Forms_Padding_Fieldset - Fatal编程技术网

Html IE8中没有字段集填充顶部

Html IE8中没有字段集填充顶部,html,css,forms,padding,fieldset,Html,Css,Forms,Padding,Fieldset,样本表格: <!DOCTYPE html> <html> <head> <title></title> <style> fieldset {padding: 50px;} </style> </head> <body> <form> <fieldset> <legend>Form</legend> <p> <l

样本表格:

<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
fieldset {padding: 50px;}
</style>
</head>
<body>
<form>
 <fieldset>
  <legend>Form</legend>
  <p>
  <label for="name">Name </label><input id="name" type="text">
  </p>
  <p>
  <label for="email">Email </label><input id="email" type="text">
  </p>
 </fieldset>
</form>
</body>
</html>

字段集{padding:50px;}
形式

名称

电子邮件


它适用于所有主流浏览器,但在IE8中没有填充top。有跨浏览器解决方案吗?

这似乎是旧版IE中的一个bug,可能是由于
图例
元素(嵌套在
字段集
中,但以特殊方式呈现)周围的一些混乱造成的,因此填充在表单上方被错误放置。我可以在怪癖模式、IE8和IE7模拟模式下或多或少地在IE9上重现这个问题


作为一种解决方法,不要在
字段集
元素上设置顶部填充。相反,在它里面的第一个普通元素上设置一个上边距(不包括
图例
元素)。

不,它没有。为了更好地说明这个问题,我只是将填充增加到50px。我已经在我安装的每个浏览器中运行了您的示例,包括ie7/8/9、firefox、chrome和opera,对于任何给定的值,填充都能按预期工作。以下是我在IE8中看到的内容:。请比较顶部和底部的填充物。是的。您可以在旧ie中的JSFIDLE中看到字段集上方的填充:将其与没有标签的字段集进行比较,该字段集没有此错误:因此,您可以做的另一个解决方案是省略图例标记,填充将正常工作。@3dgoo:但我需要图例。然后Jukka的回答解释了一种方法。