相当于CSS 中的标签?
我读到
标签已被弃用,但是我在 CSS 中找不到任何真正等效的标签。 text-align
适用于文本,但不适用于其他元素,并且自动边距仅在您知道容器的宽度时才起作用(因此,如果您事先不知道宽度,则不是解决方案)。那么这个
标签有真正的等价物吗?I read that the <center>
tag is deprecated, however I cannot find any real equivalent to it in CSS. text-align
works for text but not other elements, and auto margins only work if you know the width of the container (so not a solution if you don't know the width in advance). So is there any real equivalent to this <center>
tag?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
text-align
应该适用于其他类型的元素。这有效吗?三年后编辑 :-D
margin: auto;
也使顶部和底部边距“自动”。那可能不是你想要的。或者,您可以有类似的内容:这个特定示例将使文本水平居中,同时将上下边距硬连接到 3 个像素。
也可以说类似
margin: 3px auto 3px auto;
但我更喜欢明确地拼写出方向,因为如果我将它们全部放在一个参数上,我永远记不清参数的顺序是什么边距:
设置。text-align
should work for other kinds of elements. Does this work?Edit Three Years Later :-D
margin: auto;
also makes the top and bottom margins "auto". That might not be what you want. Alternatively you could have something like:This particular example will center the text horizontally while hardwiring the upper and lower margins to 3 pixels.
One can also say something like
margin: 3px auto 3px auto;
but I prefer spelling out the directions explicitly, as I can never quite remember what the order of the parameters are if I put them all on the onemargin:
setting.有一个区别:
There is a difference: