Firefox 中的字段集图例文本对齐右错误
有没有办法将 Firefox 中的字段集图例向右对齐?我认为这只是我的风格,但显然即使有一个在线示例,FF 字段集也会忽略文本对齐:right:
http://www.quackit.com/html/tags/html_fieldset_tag.cfm(适用于 Chrome)
is there a way to align a fieldset legend in firefox to the right? I thought it was just my styles but apparently even with an example online the FF fieldset ignores the text-align: right:
http://www.quackit.com/html/tags/html_fieldset_tag.cfm (works in chrome)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 CSS 中没有明显的方法可以做到这一点(特别是,CSS 根本无法真正描述图例/字段集样式,因此它的任何一个工作事实都是一个奇迹),但是
以获得您想要的 Firefox 行为。我很惊讶有些人看到它在测试用例上正确对齐;除了align 属性和direction: rtl 字段集之外,Gecko 中没有任何用于右对齐图例的规定。
There's no obvious way to do this in CSS (and in particular, CSS can't really describe legend/fieldset styling at all, so the fact that any of it works is a miracle), but
<legend>
has an attribute namedalign
that you can set toright
like so:to get the behavior you want in Firefox. I'm surprised some people are seeing it aligned right on that testcase; there are no provisions for aligning a legend right in Gecko except for that align attribute and
direction: rtl
fieldsets.legend
的align
属性自 HTML 4.01 起已被弃用。然而,使用float: left;
和float: right;
对齐图例元素似乎在跨浏览器中工作得相当好,尽管您可能需要在之后为第一个元素添加一些边距图例元素。The
align
attribute oflegend
has been deprecated since HTML 4.01. However aligning the legend element usingfloat: left;
andfloat: right;
seems to work fairly well across browsers, though you might need to add some margin to the first element after the legend element.我迟到了,但我通过谷歌发现了这个问题,并认为这可能会帮助将来的人
以你喜欢的方式水平放置图例,你所要做的就是设置它的
width
属性到100%
,然后将其子元素视为在单行块内,因此,例如,如果您想将内容向右对齐,当然
,不要忘记要小心标签的父宽度以避免任何行为不端
i am late to answer, but i found this question via google and thought that this might help someone in future
in order to position the legend anyhow you like horizontally, all you have to do is set its
width
property to100%
and then treat its child elements as if they were inside a one-line blockso, for example, if you want to align the contents to the right, do
of course, don't forget to be careful about label's parent width to avoid any misbehavings
我发现 Firefox 支持这样的东西
也许你可以尝试一下 - 它可能会使文本对齐在旧版本的 FF 中工作。
I found out, that Firefox supports something like this
Perhaps you could try this out - it might make text-align work in older version of FF.