假设你的标记看起来像这样:
Person:
Name:
Email:
Date of birth:
你的CSS应该是这样的:
legend {
margin:0 auto;
}
这最简单
哦,亲爱的…当涉及到浏览器的兼容性时,你可能已经选择了CSS中最困难的事情.卡梅伦·亚当斯表示最好
Probably the only difficulty in
styling semantic forms is the legend
tag. It is insufferably variable
across browsers. In Mozilla,the
legend tag is not left-indented from
the body of the fieldset,in IE and
Opera it is. In Mozilla,the legend
tag is positioned in between the
fieldset’s border and its content,in
IE and Opera it is positioned inside
the content. This makes it very hard
to move the legend inside the fieldset
border,or position it flush to the
left of the fieldset,as you get
varying effects across browsers
我解决问题的方法是完全删除字段集边框,绝对定位图例元素.你想做什么的问题是每个浏览器都有所不同.