微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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上如何表达风格的内容.

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

原文地址:https://www.jb51.cc/html/230109.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐