gpt4 book ai didi

html - 为什么 align 和 text-align 与表格不同?

转载 作者:行者123 更新时间:2023-11-28 13:51:07 26 4
gpt4 key购买 nike

你好,我正在尝试找到一种使用“讨厌的”align=center 技巧的方法..

嗯,当我查看一些代码时,我注意到两个非常相似的片段呈现的并不相同。我找不到让他们表现相同的方法。这包括用 div 替换顶层表。注意:底层表必须保留一个表,因为它在我们实际代码中非常复杂。

<table style="width: 500px;" align=center>
<tr>
<td>
<table><tr><td>
Hello there... .this is some text and such
</table></tr></td>
</td>
</tr>
</table>

删除第一行

 <table style="width: 500px;text-align: center">

使其呈现左对齐。如何在不进行过多修改的情况下使其居中呈现?

(注意这只是一个简化的示例,我们的实际站点要复杂得多)

最佳答案

text-align:center 添加到表格父容器的样式,并将 margin:0 auto 添加到表格本身,它应该按照您的方式对齐预计。 (在 FF 中测试)

编辑:删除了无效的 css“help”...我的错误。

关于html - 为什么 align 和 text-align 与表格不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1924394/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com