html - 在不知道宽度的情况下对齐 DIV 标签

标签 html css center

<分区>

Possible Duplicate:
How can I center something if I don't know ahead of time what the width is?

我想知道如何在不知道宽度的情况下对齐 div 标签。这与其他问题不同,因为我不介意使用 <center>标记,但它在 HTML 组 View 中似乎是“旧的”。请问<center>标签以后还能用吗?

谢谢

最佳答案

我通常使用 width:autowidth:100% 而不是 margin:0 auto;

但是您可以在下面的链接上看到详细信息,因为它几乎与您的问题相同!

How can I center align a div without knowing the width?

关于html - 在不知道宽度的情况下对齐 DIV 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8179319/

相关文章:

java - 如何在 JScrollPane 中将组件居中?

html - 使 div 出现在其他的旁边

javascript - jquery ajax 解析响应文本

html - CSS 网格布局 2 * 3 与多级组

html - 如何对齐 <div> 元素?

css - 内联 CSS 不居中 <div>

html - 背景图像未调整为指定的宽度和高度

html - 黑色透明滤镜的位置和宽度(CSS,bootstrap 4)

javascript - 使用 JS 关闭多个模态框

html - Bootstrap : large centered logo navbar