【发布时间】:2011-08-21 16:54:59
【问题描述】:
为什么 Firefox 4 对字段集图例的定位绝对不同于其他浏览器?
测试页面:
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8"/>
<title>Test</title>
<style type="text/css">
*
{
margin: 0;
padding: 0;
}
body
{
font-family: Tahoma, Arial, sans-serif;
font-size: 62.5%;
}
#wrapper
{
margin: auto;
padding: 1em;
width: 720px;
}
form
{
width: 670px;
padding: 25px;
background-color: #ffffff; /* White */
color: #000000; /* Black */
border: 1px solid #cccccc; /* Gray */
font-size: 12px;
}
fieldset
{
position: relative;
border: 1px solid #cccccc; /* Gray */
padding: 25px 10px 5px 15px;
margin-bottom: 20px;
}
fieldset legend
{
position: absolute;
top: 5px;
left: -10px;
/* Firefox */
/*top: -20px;
left: -25px;*/
font-weight: 900;
background-color: #ffffff; /* White */
}
/* Input Types */
label
{
margin-right: 10px;
line-height: 20px;
}
</style>
</head>
<body>
<div id="wrapper">
<form method="POST" action="test" id="testForm">
<fieldset>
<legend>Test</legend>
<label for="test">Test:</label><input type="text" id="test" name="test" value=""/>
</fieldset>
<input type="submit" value="Test"/>
</form>
</div>
</body>
</html>
请注意,在 Opera 11.10 Build 2092、Chrome 11.0.696.65、Safari 5.0.4 (7533.20.27) 和 Windows Internet Explorer 9 中,它们会在左侧显示图例,与字段集边框重叠。
在 Firefox 4.0.1 中,我必须更改 top 和 left 属性才能获得类似的效果。例如,在测试页的style 标记内,取消注释此 CSS:
/* Firefox */
/*top: -20px;
left: -25px;*/
【问题讨论】:
-
我相信您已经注意到 Firefox 4 有很多困难和奇怪之处。我已经退回到 3.6.17;我会等几周,直到第 4 版完成。
-
@Pete FF4 于 3 月 22 日发布(非测试版)。它在 Acid3 test 上的得分为 97/100(与 Chrome 11 的得分完全相同)。是什么让您认为“几周后”一切都会发生变化?
标签: css firefox css-position firefox4 legend