html – 如何居中的元素 – 使用什么而不是align:center属性?

在这里缺少什么?

编辑,因为这在注释中不起作用:

以下解决方案导致:

----------------------------------------------------
|                                                  |
|                     Legend text                  |

但我要做的是:

----------------------Legend text-------------------
|                                                  |
|                                                  |

编辑#2:

根据迄今为止的反馈,这听起来像这个整体< legend>标签一个失败的命题.有人有一个例子,他们用什么代替这个 – 有类似外观更可靠的东西?

解决方法

假设你的标记看起来像这样:
<form>
<fieldset>
<legend>Person:</legend>
Name: <input type="text" size="30" /><br />
Email: <input type="text" size="30" /><br />
Date of birth: <input type="text" size="10" />
</fieldset>
</form>

你的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

您可以阅读更多关于他在Fancy Form Design Using CSS上如何表达风格的内容.

解决问题的方法是完全删除字段集边框,绝对定位图例元素.你想做什么的问题是每个浏览器都有所不同.

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些